WKWebView加载返回其他错误码还是会回到加载完成的回调而不是错误回调
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation;
需要在这个地方处理下
//服务器返回200以外的状态码时,都调用请求失败的方法。
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{if (((NSHTTPURLResponse *)navigationResponse.response).statusCode == 200) {decisionHandler (WKNavigationResponsePolicyAllow);}else {decisionHandler(WKNavigationResponsePolicyCancel);}
}