JimmyJammed
JimmyJammed

Reputation: 9698

iOS - UITableView Detect When Finger Crosses Keyboard While Scrolling

I have a feature in my app very similiar to the native Messages app. I like how the keyboard gets hidden when the messages table is scrolled and your finger crosses the keyboard UI.

I want to mimic this behavior and was wondering if there was an easy way of detecting this?

Upvotes: 0

Views: 221

Answers (2)

JimmyJammed
JimmyJammed

Reputation: 9698

I discovered a great library that handles this for you. It imitates the Messages app exactly and is easy to setup and use: http://www.cocoacontrols.com/platforms/ios/controls/dakeyboardcontrol

Upvotes: 1

Marco Tolman
Marco Tolman

Reputation: 319

Looking at the Messages app the logic for when the keyboard animates down does not seem to be linked to sections in the tableview. In one of my message threads it starts animating down when the top of the keyboard is in the middle of one of the message bubbles. I think the contentOffset of the tableview is just tracked and when it crosses a certain amount the keyboard starts to animate off the screen. You can track the contentOffset each time the user starts dragging the tableview by implementing the

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

and

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

methods from the UIScrollViewDelegate protocol.

Upvotes: 0

Related Questions