Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss keyboard with swipe gesture (as in Message app)

When the keyboard is showing on the iPhone's Messages app, if the user begins a swipe down from the messages tableview and continues into the keyboard area, the keyboard will begin to dismiss. If they move their finger up and down during this process, the keyboard moves with it.

Are Apple doing this with private APIs, or is there a way to control the keyboard like this from (I presume) a gesture recognizer?

like image 321
Michael Stet Avatar asked Aug 20 '11 17:08

Michael Stet


People also ask

How do I hide the keyboard on Facebook Messenger?

It can be hard to view a conversation when reading texts in the Messages app because the keyboard blocks half the screen. To hide it, slide your finger down from above the text-entry box and the keyboard will start to disappear.

What is swipe gesture?

You can swipe left or right from the Apps screen of your Android phone or tablet to see more pages of apps. When you're using a web browser or an app such as Facebook or WhatsApp, you can swipe up to move down the page, and swipe back down to return to where you started.


2 Answers

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.

like image 69
Daniel Amitay Avatar answered Sep 28 '22 08:09

Daniel Amitay


The simplest solution is to set the following two properties:

  • UIViewController : UIResponder inputAccessoryView
  • UITableView : UIScrollView keyboardDismissMode

Boom, baby!

Check out Acani Chats iPhone Client ChatViewController.swift for an example.

like image 25
ma11hew28 Avatar answered Sep 28 '22 07:09

ma11hew28