Dismiss keyboard with swipe gesture (as in Message app) Dismiss keyboard with swipe gesture (as in Message app) ios ios

Dismiss keyboard with swipe gesture (as in Message app)


I created a UIView category that provides the desired functionality:

https://github.com/danielamitay/DAKeyboardControl

Edit:It has indeed been used on the app store.


Luckily, Apple added the handy property keyboardDismissMode on UIScrollView to make your life a little easier.

Now your app can behave like Messages.app just by changing a single property on your Storyboard, or alternatively by adding one line of code!

This property uses the new UIScrollViewKeyboardDismissMode enum. The possible values of this enum are as follows:

UIScrollViewKeyboardDismissModeNone        // the keyboard is not dismissed    automatically when scrollingUIScrollViewKeyboardDismissModeOnDrag      // dismisses the keyboard when a drag beginsUIScrollViewKeyboardDismissModeInteractive // the keyboard follows the dragging touch off screen, and may be pulled upward again to cancel the dismiss

Here’s the Storyboard property to change to dismiss the keyboard on scroll:

enter image description here

Hope that helps solving your problem