- (void)webView:(WKWebView *)webView
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if (webView != _webView) { return; }
NSURL *url = navigationAction.request.URL;
__strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate;
if ([_base isCorrectProcotocolScheme:url]) {
if ([_base isBridgeLoadedURL:url]) {
[_base injectJavascriptFile];
} else if ([_base isQueueMessageURL:url]) {
[self WKFlushMessageQueue];
} else {
[_base logUnkownMessage:url];
}
**decisionHandler(WKNavigationActionPolicyCancel); // executed**
}
if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) {
**[_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler]; // executed**
} else {
decisionHandler(WKNavigationActionPolicyAllow);
}
}
I implement the selector @selector(webView:decidePolicyForNavigationAction:decisionHandler:)
and execute "decisionHandler(WKNavigationActionPolicyAllow);"
It seems the decisionHandler can be called twice and cause the crash.
No such thing has happened before...
I implement the selector @selector(webView:decidePolicyForNavigationAction:decisionHandler:)
and execute "decisionHandler(WKNavigationActionPolicyAllow);"
It seems the decisionHandler can be called twice and cause the crash.
No such thing has happened before...