iOS点击空白处或点击背景收起键盘
在viewDidLoad中添加手势
- (void)viewDidLoad{
[super viewDidLoad];
//添加手势
UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];}
然后 实现方法即可
-(void)viewTapped:(UITapGestureRecognizer*)tap1
{
[self.view endEditing:YES];
}
原文地址:http://blog.csdn.net/bjourney/article/details/46861059