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.
The simplest solution is to set the following two properties:
Boom, baby!
Check out Acani Chats iPhone Client ChatViewController.swift
for an example.
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:
Hope that helps solving your problem