WKWebView - didFailProvisionalNavigation not called when component fails

I am trying to register an error when the page component loaded in WKWebView does not work, but didFailProvisionalNavigation not called.

I deleted the css file from my page to check it, but there is no result.

When I load a page in Google Chrome, I can find the missing file

enter image description here

WKWebView is initialized as:

 @interface MyWebView : UIViewController <WKNavigationDelegate> @property(strong,nonatomic) WKWebView *loginWebView; @end 

.M file

 @implementation MyWebView - (void) initWebView { // Set and Load the WebView self.webView = [[WKWebView alloc] initWithFrame:self.view.frame]; self.webView.navigationDelegate = self; [self.webView loadRequest:request]; [self.view addSubview:self.webView]; } 

Then I implemented the following methods:

 webView:decidePolicyForNavigationAction:decisionHandler: webView:didStartProvisionalNavigation: webView:didFinishNavigation: webView:didFailNavigation:withError: webView:didFailProvisionalNavigation:withError: 

The first three methods are called, but neither didFailNavigation nor didFailProvisionalNavigation are called

Having studied the documentation for didFailProvisionalNavigation , we have

Called when an error occurs when the web view loads content.

Well, the content did not work (css file) and the method is not called, how can I do this?

PS: I also tried using UIWebView !

+5
source share

Source: https://habr.com/ru/post/1261329/


All Articles