在 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;