1.通过手势
1 | UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide)]; |
2.view的touchesBegan
1 | -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ |
3.UIScrollView
1 | -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { |
或者
1 | self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; |