iOS UIScrollView点击空白结束编辑、收起键盘已知有三种方法。
-
添加点击手势事件
- .xib/.storyboard实现
/**
点击空白取消键盘
@param sender scrollView
*/
- (IBAction)tapSpace:(id)sender {
[self.view endEditing:YES];
}
- 设置UIScrollView的属性
keyboardDismissMode
为UIScrollViewKeyboardDismissModeOnDrag
.xib/.storyboard实现
scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;