Dismiss keyboard with swipe gesture (as in Message

2019-03-08 07:45发布

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?

8条回答
等我变得足够好
2楼-- · 2019-03-08 08:31

I think the best way is to place a hidden button above the text input container. a long strip and when it detects a touchdown and release or cancel then hide the keyboard.

I'm going to try it and i will let you know how i go.

查看更多
叼着烟拽天下
3楼-- · 2019-03-08 08:31

Short answer; They're most likely doing some 'Private API' thing there.

I'm most sure that the keyboard is in an independent view, above your app's window (You do not have access/control to it and it always displays on top, no matter what). The most you can do is have the input view become/resign first responder status, and the keyboard will appear/disappear accordingly: All or nothing.

You may be able to get a handle of the keyboard view and change its frame property (using undocumented properties of documented classes, and undocumented classes), but I'm pretty sure that will get you kicked out of the store.

查看更多
登录 后发表回答