标签:
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];
}
标签:
原文地址:http://www.cnblogs.com/Dandan-King/p/4983644.html