UITextField回收键盘
1.通过代理方法回收键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
2.点击空白区域回收键盘
// 收回键盘
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self endEditing:YES];
}
网友评论