我有一个电话间隙应用程序,它在子浏览器中加载一个 HTML 5 应用程序。在子浏览器中加载的页面上的链接也会在子浏览器中加载。我希望这些链接在 Safari 中打开。我怎么能这样做?
谢谢
我有一个电话间隙应用程序,它在子浏览器中加载一个 HTML 5 应用程序。在子浏览器中加载的页面上的链接也会在子浏览器中加载。我希望这些链接在 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 ];
}
}
希望这可以帮助