我已将整个html文档与转义序列存储在变量中... 它包含一些锚标签..如果已经点击,它应该在safari中打开,而不是在我的应用程序webview ....
答案 0 :(得分:4)
您可以使用以下代码。
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
答案 1 :(得分:3)
您可以使用UIWebViewDelegate协议来实现此目的:
// assuming webView is a valid UIWebView
webView.delegate = self;
- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)rq navigationType:(UIWebViewNavigationType)nt
{
if (nt == UIWebViewNavigationTypeLinkCkicked) {
[[UIApplication sharedApplication] openURL:[rq URL]];
return NO;
}
return YES;
}