-1

How can I implement the drag-to-hide-keyboard gesture? Similar to Facebook's Messenger and Messages app on iOS. In Messages app or FB app, Skype app, etc..., if user drags from outside to inside of keyboard frame, keyboard will move as user's touch drags toward the bottom. It means the keyboard may be only appear just a half on screen when the finger still on touch screen. I've searched but can't find any info about this. Is it native feature or do we have to custom it? If custom, how can I do it?

Peyman
  • 3,059
  • 1
  • 33
  • 68
Dummy307
  • 177
  • 1
  • 7
  • Possible duplicate of [UIScrollView - Move keyboard with touch drag like iOS 7 mail app?](https://stackoverflow.com/questions/21335103/uiscrollview-move-keyboard-with-touch-drag-like-ios-7-mail-app) – nschum Aug 14 '17 at 23:49

4 Answers4

2

Simply you can use

scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

Or you can add a tap gesture recognizer and add target to dismiss your keyboard using resignFirstResponder. hope it helps!

Vinu David Jose
  • 2,569
  • 1
  • 21
  • 38
1

I think it will work if you add scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; or [self.view endediting = YES];

Thank you

Jose
  • 31
  • 6
0
UIScrollView.keyboardDismissMode
Deividi Cavarzan
  • 10,034
  • 13
  • 66
  • 80
Mark Krenek
  • 4,889
  • 3
  • 25
  • 17
0

You can try using code below, using when scroll view to hidden keyobard.

func scrollViewWillBeginDragging(scrollView: UIScrollView) {
    self.view.endEditing(true)
}

or you can resgister gesture for view you want touch to hidden keyboard and put code

self.view.endEditing(true)

into action of gesture

Vu Dao
  • 1
  • 4