ShouldStartLoadWithRequest does not load links when clicking on UIWebView

I started using shouldStartLoadWithRequest and ran into cryptic behavior, as I understand it. It has the simplest form, I tried the following ...

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{
  return YES;
}

With a side effect, when I click on HTML links, links do not load new pages in UIWebView. Most likely, I don’t understand anything at all here. Any feedback / help would be greatly appreciated.

+3
source share
1 answer

Two possible reasons

1> either you did not set the delegate Set the delegate of your web view to your class i.e. to the viewDidLoadmethod

webView.delegate = self; 

(if the webView is taken in an xib file, you need to install the delegate from the sib file)

2 > UIWebViewDelegate .. ,

@interface RootViewController : UIViewController<UIwebViewDelegate>
+8

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


All Articles