子ブラウザーに HTML 5 アプリを読み込む phone gap アプリがあります。子ブラウザに読み込まれたページにあるリンクも、子ブラウザに読み込まれます。これらのリンクを Safari で開くことを希望します。どうすればそれができますか?
ありがとう
子ブラウザーに HTML 5 アプリを読み込む phone gap アプリがあります。子ブラウザに読み込まれたページにあるリンクも、子ブラウザに読み込まれます。これらのリンクを Safari で開くことを希望します。どうすればそれができますか?
ありがとう
これを AppDelegate.m に追加するだけです。
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
お役に立てれば