iOS UIScrollView点击空白收起键盘

iOS UIScrollView点击空白结束编辑、收起键盘已知有三种方法。


  • 添加点击手势事件

    1. .xib/.storyboard实现
    • iOS UIScrollView点击空白收起键盘_第1张图片
      tips_Gesture.jpg
    • iOS UIScrollView点击空白收起键盘_第2张图片
      tips_TapSpace.jpg
/**
 点击空白取消键盘
 
 @param sender scrollView
 */
- (IBAction)tapSpace:(id)sender {
    [self.view endEditing:YES];
}
  • 设置UIScrollView的属性 keyboardDismissModeUIScrollViewKeyboardDismissModeOnDrag
    • .xib/.storyboard实现

    • iOS UIScrollView点击空白收起键盘_第3张图片
      tips_TapSpace1.jpg
scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

你可能感兴趣的:(iOS UIScrollView点击空白收起键盘)