リンクを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];
}

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];
}
}

This entry was posted on 金曜日, 3月 2nd, 2012 at 4:19 PM and is filed under iOS, PhoneGap. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。