Hide keyboard by dragging your finger like sms app in iOS 5

I have a chat function in my application and I'm trying to hide the keyboard by dragging my finger down, just like you can hide the keyboard in an sms application in iOS 5.

I have subclassed the UITableView, however, as soon as the scrolling begins, I no longer receive calls

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 

I am wondering how I can get the scroll and find out where the finger is while scrolling, so if it starts to get closer to the keyboard, I can hide it.

I think this is a feature that many people want, any ideas on how to do this?

+7
source share
5 answers

DAKeyboardControl is the source of the MIT license code for what you are looking for.

+7
source

Googling further showed that this question is a duplicate:

How to move iPhone keyboard like in Messaging.app?

+4
source

I enabled this feature in my application using the Daniel DAKeyboardControl library . You can implement an iMessage keyboard that hides acidity with just one line:

 [self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) { // Move interface objects accordingly // Animation block is handled for you }]; 
+3
source

UITableView inherits from UIScrollView, so you can determine the scroll position using UIScrollViewDelegate methods such as - (void)scrollViewDidScroll:(UIScrollView *)scrollView

+2
source

True in iOS 7, Apple added a convenient keyboardDismissMode property to UIScrollView . Now your application can behave like Messages by simply changing one property on your storyboard or adding one line of code.

This property uses the new ScrollViewKeyboardDismissMode enumeration. Possible values ​​for listing are as follows.

 UIScrollViewKeyboardDismissModeNone UIScrollViewKeyboardDismissModeOnDrag UIScrollViewKeyboardDismissModeInteractive 

Here is the storyboard property if you release the keyboard on the scroll

+2
source

All Articles