wkWebView 點(diǎn)擊鏈接無反應(yīng)?
多半是因?yàn)榫W(wǎng)頁(yè)中有target="_blank" 在新窗口打開鏈接
而你有沒有實(shí)現(xiàn)wkWebView的navigationDelegate的兩個(gè)方法
?//self.wkWebView.navigationDelegate = self; 設(shè)置代理
//實(shí)現(xiàn)navigationDelegate的兩個(gè)方法
-(void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler{
//如果是跳轉(zhuǎn)一個(gè)新頁(yè)面
if(navigationAction.targetFrame ==nil) {
?[webView loadRequest:navigationAction.request];
?}?
?decisionHandler(WKNavigationActionPolicyAllow);
}
-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
? ? NSLog(@"createWebViewWithConfiguration");
? ? if (!navigationAction.targetFrame.isMainFrame) {
? ? ? ? [webView loadRequest:navigationAction.request];
? ? }
? ? return nil;
}