PhoneGap:在 Safari 中打开外部 URL [英] PhoneGap: Opening external URL's in Safari
问题描述
我刚刚升级到 PhoneGap 1.6.1,但无法再在 Safari 中打开外部 URL.
I've just upgraded to PhoneGap 1.6.1 and I can no longer get external URL's to open in Safari.
在此版本之前,我对 AppDelegate.m 进行了如下修补:
Prior to this version I had patched AppDelegate.m as follows:
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
if ([[url scheme] isEqualToString:@"http"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
} else {
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
我注意到之前有人问过类似的问题:如何在 Safari 中打开外部链接而不是应用的 UIWebView?
I notice that a similar question has been asked before: How can I open an external link in Safari not the app's UIWebView?
但在我看来这个答案不再适用于 1.6.1 版.
But it looks to me like this answer no longer works on version 1.6.1.
我也试过在 Cordova.plist 中设置 OpenAllWhitelistURLsInWebView,但没有一个设置给我 Safari.
I've also tried setting OpenAllWhitelistURLsInWebView in Cordova.plist but neither setting gives me Safari.
提前致谢.
推荐答案
升级到 Cordova 1.6.1 后遇到同样的问题.
Had the same problem after upgrading to Cordova 1.6.1.
尝试添加target="_blank"
到您的链接.
这对我有用.
这篇关于PhoneGap:在 Safari 中打开外部 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!