UIWebView 更换 WkWebView 一一对应的方法名


UIWebView、WkWebView:

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

{}

- (void)webView:(WKWebView *)webView didFailLoadWithError:(nonnull NSError *)error

{}

UIWebView、WkWebView:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

{

NSURL *url = request.mainDocumentURL;

NSString *scheme = request.URL.scheme;

//NSString *absoluteString = [url absoluteString];

NSString *host = [url host];

NSString *query = [url query];

return YES;

}

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler

{

NSURL *url = navigationAction.request.URL;

NSString *scheme = navigationAction.request.URL.scheme;

NSString *host = [url host];

NSString *query = [url query];

//切记加上这句

decisionHandler(WKNavigationActionPolicyAllow);

}

你可能感兴趣的:(UIWebView 更换 WkWebView 一一对应的方法名)