2

I'm curious how iOS 7 mail app is moving and dismissing the keyboard according to user's touch drag on new message screen.

Also it's implemented on comments screen of instagram app.

Can it be implemented through public apis?

Jun
  • 3,422
  • 3
  • 28
  • 58
  • Do you just want to dismiss the keyboard or also "move" with the touch of the user? – fahu Jan 24 '14 at 14:39
  • See this question: http://stackoverflow.com/questions/6457239/ios-how-to-access-the-uikeyboard – Putz1103 Jan 24 '14 at 14:44
  • 1
    They say it's private and undocumented, but possible. It may get your app rejected from the app store. – Putz1103 Jan 24 '14 at 14:44
  • It's implemented in instagram comments screen. – Jun Jan 24 '14 at 17:32
  • @EgorT How are they able to drag the text field along with it though? In my case the dismissal begins right as the touch passes the top of the keyboard but I want it to begin a little higher. Any thoughts? – Stefan Dec 30 '18 at 00:36

2 Answers2

4

UIScrollView has a property called keyboardDismissMode that allows you to set different behaviours. I think this is what you want:

scrollview.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
James P
  • 4,786
  • 2
  • 35
  • 52
0

In your view controller just using [self.view endEditing:YES]; when the user taps on the view. For the drag animation you have to use CoreAnimation and gesture recognizer based on keyboard frame.

Fry
  • 6,235
  • 8
  • 54
  • 93