1.一般的view上收起键盘
// 手势
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.cellphone resignFirstResponder];
[self.password resignFirstResponder];
}
2.tableView 上收起键盘
// 通过滚动收起
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[tf resignFirstResponder];
[self.name resignFirstResponder];
}
// 通过手势
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tableViewGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(commentTableViewTouchInSide)];
tableViewGesture.numberOfTapsRequired = 1;
tableViewGesture.cancelsTouchesInView = NO;
[self.tableView addGestureRecognizer:tableViewGesture];
}
- (void)commentTableViewTouchInSide{
[tf resignFirstResponder];
[self.name resignFirstResponder];
}