答案 0 :(得分:3)
您需要创建UITapGestureRecognizer
!
首先在标题(.h)文件中定义UITapGestureRecognizer
。
然后在viewDidLoad
:
tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(closeKeyBoard)];
[self.view addGestureRecognizer:tapGesture];
现在关闭键盘的方法:
-(void)closeKeyBoard {
[self.view endEditing:YES];
}
这就是你所需要的一切!
干杯