2015-07-21 36 views

回答

0

首先,你必须实现Web视图的委托方法:

- (BOOL)webView:(UIWebView *)_webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 

现在尝试检测要在Safari浏览器

打开网址
- (BOOL)webView:(UIWebView *)_webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
    { 
     NSString urlLoading = request.URL.absoluteString; 
     if ([urlLoading isEqualToString:@"url_that_you_want_to_load"]) { 
     [webView stopLoading]; 
     //open url in external browser 
     [[UIApplication sharedApplication] openURL:request.URL]; 
     } 
     return YES; 
    }