Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UIWebView intercept link click

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.

like image 972
ghiboz Avatar asked Dec 08 '11 20:12

ghiboz


1 Answers

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.

like image 187
Chris Wagner Avatar answered Oct 21 '22 20:10

Chris Wagner