1

I have a UIWebView that is loaded with a url as soon as my application is loaded.

The webpage have different links that the user can go to.

I want to be able to see what links they are going to and also be able to change the url if they match a certain text. I do not care about ajax requests(they will not match the text).

Is there any function that i can use for this?

Lasse Sviland
  • 1,479
  • 11
  • 23

1 Answers1

1

You must implement a UIWebViewDelegate. One of its methods is webView:shouldStartLoadWithRequest:navigationType:, which is called whenever the user navigates to another URL. From the NSURLRequest passed in you can get the URL. The last parameter (UIWebViewNavigationType) tells you what user action led to the request, e.g. click on a link in the page.

Rudi Angela
  • 1,463
  • 1
  • 12
  • 20
  • 1
    Alternatively, for **WKWebview**, instead of `shouldStartLoadWithRequest`, use `decidePolicyForNavigationAction` instead as example [here](https://stackoverflow.com/a/37513449/1423345). _Note that I did not put this as a separate answer as OP asked for UIWebView_ – Dan Nov 23 '18 at 13:42