リンクをsafariで開く | phonegap iOS
外部ページもアプリで開いてしまうので、外部リンクは、safariで開くように変更します。
Classes AppDelegate.mを編集します。
– (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
{
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
http://groups.google.com/group/phonegap/browse_frm/thread/7815d5e103fc18ac/a3ba58b1002af281?#a3ba58b1002af281
webViewを利用している人は、ここにドメインの振り分けを追加する感じで。
– (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
if( [[url scheme] isEqualToString:@”http”] ||
[[url scheme] isEqualToString:@”https”])
{
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else
{
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
{
NSURL *url = [request URL];
if( [[url scheme] isEqualToString:@”http”] ||
[[url scheme] isEqualToString:@”https”])
{
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else
{
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}