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?
Asked
Active
Viewed 969 times
4 Answers
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
-
Great!! In my case, I mention to UIScrollViewKeyboardDismissModeInteractive mode. Thanks. – Dummy307 Nov 26 '15 at 03:25
1
I think it will work if you add scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
or [self.view endediting = YES];
Thank you

Jose
- 31
- 6
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