2012-07-04 67 views
0

我正在尝试使用以下锚点标签链接到外部链接: Google在iOS中使用Phonegap打开外部链接

为了做到这一点,我在appDelegate.m添加该代码(代码是从这里:https://gist.github.com/2012253):

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

,但我不能仍然能够链接到谷歌......上午我做错了什么?需要一些帮助。

+0

您是否正确设置了“ExtrernalHosts”属性?你的网址在应用程序中打开? – dhaval

+0

网址未在应用程序中打开...如何设置外部主机? – lakesh

+0

在您的Cordova.plist文件,详细信息 - http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide – dhaval

回答

0

我已经使用的是一块代码在MainViewController.m科尔多瓦1.7。 0 cordova 1.9.0和cordova 2.1.0,它工作得很好。您只需将该代码移动到正确的文件。

相关问题