问题
调用WKWebView的时候,有些页面会打开新的一页,导致WKWebView出现闪退日志:
代码语言:javascript复制2020-05-14 21:36:51.793103 0800 GDNXBankProject[6797:3353899] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Returned WKWebView was not created with the given configuration.'
解决问题
在原来的WebView进行读取新的页面,代码:
代码语言:javascript复制#pragma mark - WKUIDelegate
// 创建一个新的WebView
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
//修复'Returned WKWebView was not created with the given configuration.'问题
if (!navigationAction.targetFrame.isMainFrame) {
[webView loadRequest:navigationAction.request];
}
return nil;
}