UIWebView and Undo Gesture Gestures

I have a main xib window on an iPad. In the main window there are disk gesture recognizers that show / hide the toolbar when the user removes the screen. The main window also has a web view.

How can I cancel gestures if a user clicks a link in a web view? I don’t want the toolbar to switch if they hit the link.

thanks

+4
source share
1 answer

You need to check if the view should get a touch:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { // test if our control subview is on-screen if (self.view.superview != nil) { if ([touch.view isKindOfClass:[UIWebView class]]) { // we touched our UIWebView return NO; // ignore the touch } } return YES; // handle the touch } 

If you want to use UITapGestureRecognizer, you need to subclass UIWebView as described here: https://github.com/psychs/iphone-samples/tree/4028ab78af92ab17465338575b78ed80310a613f/WebViewTappingHack

+5
source

All Articles