How to override UIWebView links request action with your own custom method

If you did not understand from the post title what I am trying to say, here is another explanation. If you have an instance of UIWebView class implemented in your view and you want to call one of your custom method when user clicks on link in that UIWebView instance, first thing you must do to achieve that is set the delegate of that UIWebView class instance on you instance of UIViewController class. This is almost in same time last thing. Now just copy&paste this code into your class that implements UIWebView instance and add call to your method.

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
if (overrideLinksSwitch.on == TRUE) {
[self myMethodAction];
[myWebView stopLoading];
return YES;
else {
return YES;
return YES;

You can download example app here.

You made it all the way down here so you must have enjoyed this post! You may also like:

Custom shipping method in Magento Stjepan Udovicic
, | 44

Custom shipping method in Magento

Apple push notifications from Magento Darko Goles
Darko Goles, | 5

Apple push notifications from Magento

Magento API v2 SOAP demystified Darko Goles
Darko Goles, | 39

Magento API v2 SOAP demystified


  1. Nice post 🙂 it helped me. but i have a que , whether same implementation can be done , if it is not webview?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.