点击 UITableView 隐藏键盘
在 UITableView 上加手势
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[self.tableView addGestureRecognizer:gestureRecognizer];
- (void) hideKeyboard {
[textField1 resignFirstResponder];
[textField2 resignFirstResponder];
...
...
}
ps:加上这句不会影响你 tableview 上的 action (button,cell selected...)
gestureRecognizer.cancelsTouchesInView = NO;
原帖地址: http://stackoverflow.com/questions/2321038/dismiss-keyboard-by-touching-background-of-uitableview