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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Alternatively, for WKWebview, instead of shouldStartLoadWithRequest, use decidePolicyForNavigationAction instead as example here. Note that I did not put this as a separate answer as OP asked for UIWebView

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.