Created
August 8, 2012 10:12
-
-
Save timd/3293993 to your computer and use it in GitHub Desktop.
Adding UIGestureRecognizer to UIWebView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add gesture recognizer to UIWebView: | |
UITapGestureRecognizer *tapCatcher = [[UITapGestureRecognizer alloc] init]; | |
[tapCatcher setNumberOfTapsRequired:1]; | |
[tapCatcher setNumberOfTouchesRequired:1]; | |
[tapCatcher setDelegate:self]; | |
[tapCatcher addTarget:self action:@selector(didTapOnView)]; | |
[self.webView addGestureRecognizer:tapCatcher]; | |
Make sure view controller conforms to UIGestureRecognizerDelegate | |
Implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: | |
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { | |
return YES; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment