iOS UIWebView intercept link click

14,662

Yes, look at the UIWebViewDelegate Protocol Reference, specifically webView:shouldStartLoadWithRequest:navigationType:

The NSURLRequest will let you know where the link they clicked is going to direct them.

You would simply return NO on this method if you want to prevent the request from loading.

Share:
14,662

Related videos on Youtube

ghiboz
Author by

ghiboz

c# programmer for work, php, objective-c, c++ programmer for passion

Updated on June 04, 2022

Comments

  • ghiboz
    ghiboz over 1 year

    Is it possible intercept when a user clicks a link in a UIWebView and retrieve the link?

    I wish to block the UIWebView from going to the clicked link and do something else.

    Thanks in advance.

  • fatdragon
    fatdragon over 8 years
    I need to retrieve the content to memory only, examine it and if it's ok then display it in UIWebView. Is that possible?
  • Chris Wagner
    Chris Wagner over 8 years
    You might want to use an NSURLConnection to download the content do you check, and then load that from disk into a webview if I understand correctly.