项目更换了WKWebView之后,一些webview中的超链接没办法触发,需要实现navigationDelegate协议才可以
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
// 通过浏览器访问
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
decisionHandler(WKNavigationActionPolicyCancel);
} else {
decisionHandler (WKNavigationActionPolicyAllow);
}
return ;//不添加会崩溃
}
网友评论