Skip to content

Instantly share code, notes, and snippets.

@timd
Created August 8, 2012 10:12
Show Gist options
  • Save timd/3293993 to your computer and use it in GitHub Desktop.
Save timd/3293993 to your computer and use it in GitHub Desktop.
Adding UIGestureRecognizer to UIWebView
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