UITapGestureRecognizer *gestureRecognizer =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
gestureRecognizer.cancelsTouchesInView = NO;
[self.navigationController.view addGestureRecognizer:gestureRecognizer];
2.
- (void)hideKeyboard
{
// This trick dismissed the keyboard, no matter which text field or text
// view is currently active.
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
}
沒有留言:
發佈留言