typedef NS_ENUM(NSInteger, UIScrollViewKeyboardDismissMode) {
UIScrollViewKeyboardDismissModeNone,
//當(dāng)拖動時就隱藏鍵盤
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;