webView 点击页面跳转到浏览器
@interface ForumDetailViewController ()<UIWebViewDelegate>
{
NSUInteger _clickedNumber;
}
@end
- (void)viewWillAppear:(BOOL)animated
{
_clickedNumber = 0;
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
if (_clickedNumber>=1) {
[[UIApplication sharedApplication]openURL:request.URL];
}
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
return NO;
}
_clickedNumber++;//定义的属性,因为第一次进入的时候会走此方法,点击webView里面链接的时候才回走第二次,所以当_clickedNumber>=1的时候才会到浏览器
return YES;
}