UIScrollView滑动收起系统键盘

typedef NS_ENUM(NSInteger, UIScrollViewKeyboardDismissMode) {
    UIScrollViewKeyboardDismissModeNone,
//当拖动时就隐藏键盘
    UIScrollViewKeyboardDismissModeOnDrag,      // dismisses the keyboard when a drag begins
//键盘会跟随拖动手动进行处理,向下滑动会隐藏键盘,同时向上滑动会取消隐藏
    UIScrollViewKeyboardDismissModeInteractive, // the keyboard follows the dragging touch off screen, and may be pulled upward again to cancel the dismiss
} NS_ENUM_AVAILABLE_IOS(7_0);

@property(nonatomic) UIScrollViewKeyboardDismissMode keyboardDismissMode NS_AVAILABLE_IOS(7_0); // default is UIScrollViewKeyboardDismissModeNone

所以不用在UIScrollView的代理方法进行操作了,直接使用下面代码就可以做到滑动时收起键盘

self.scrollView.keyboardDismissModel = UIScrollViewKeyboardDismissModeOnDrag;

你可能感兴趣的:(UIScrollView滑动收起系统键盘)