点击view或者tableview隐藏键盘
一般view
```
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[textFiled resignFirstResponder];
}
```
tableView里面添加手势
#pragma 添加手势
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[self.tableview addGestureRecognizer:gestureRecognizer];
gestureRecognizer.cancelsTouchesInView = NO; //很关键,如果没有这个,tableView的cell的点击事件不会响应。
网友评论