Skip to content

Instantly share code, notes, and snippets.

@jkyin
Created August 30, 2014 07:50
Show Gist options
  • Save jkyin/6e7042b28832ff4a752f to your computer and use it in GitHub Desktop.
Save jkyin/6e7042b28832ff4a752f to your computer and use it in GitHub Desktop.
UIWebView dismiss keyboard
// implement <UIGestureRecognizerDelegate>
{
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
tapRecognizer.delegate = self;
[self.webView addGestureRecognizer:tapRecognizer];
}
- (void)tap:(UITapGestureRecognizer *)gr
{
NSLog(@"Tap!");
[self.webView endEditing:YES];
}
- (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