So I would like to detect a tap on UIWebView if it is not tapping on a link. How do I do this? I know that:
- (BOOL)webView:(UIWebView *)webview shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
is called every time a link is clicked. However how do I know if it’s a tap on the UIWebView that is other than the link? I’ve been searching for the web and the closest I found is this. However that does not tell me whether the tap is on a link or not
I feel the following method should work theoretically. You could do is wrap your
UIWebViewin aUIViewcontainer and set your gesture recognizers on the container view. Then the touch events that are not handled by theUIWebViewwill be passed up the view hierarchy and be intercepted by your container view.In the container
UIViewimplement the appropriate handlers & you can detect taps. Hope this is clear…If this approach is not bearing fruit, then you could go the javascript route. i.e. place javascript events as webPage loads & you are good to go. See here for more – Does UIGestureRecognizer work on a UIWebView?