好吧,我已经通过本机方面实现了这一点(目标 C)
在“MainViewController.m”中添加此方法
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
NSString *str = url.absoluteString;
NSRange range = [str rangeOfString:@"http://"];
NSRange range1 = [str rangeOfString:@"https://"];
if (range.location != NSNotFound || range1.location != NSNotFound) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
这会处理 iOS6 和 iOS7 的“http”和“https”链接,并在设备的默认浏览器中打开链接。