Lift the keyboard by scrolling the UITableView and scrolling along with the table

To add panning behavior to the keyboard, I use DAKeyboardControl . It works great (after modifications) to control panning to close the keyboard.

How to make the keyboard appear if the user tries to scroll down (finger up) at the end UITableView. To be more specific, I am looking for behavior similar to the Facebook Messages application, where if you scroll up the keyboard, pan and scroll with the table.

EDIT : It seems I don't quite understand what I want. I want to move the keyboard along with scrollview ( UITableView). In the following image, I am browsing the keyboard along with a table. The table is already scrolling to the bottom, and if I try to scroll down, the keyboard will begin to appear. Meanwhile, my finger is in the middle of the table.

enter image description here

+4
source share
3 answers

This effect can be achieved by setting scrollview keyboardDismissModeto UIScrollViewKeyboardDismissModeInteractive, and then to scrollViewDidScroll:, the caller [textField becomeFirstResponder];. Since you are in the middle of scrolling, the keyboard will respect the property keyboardDismissModeand will be interactively displayed. Take off DAKeyboardControl; he is out of date.

+8
source

.h...

@property (nonatomic, assign) CGFloat lastContentOffset

.m ...

- (void)scrollViewDidScroll:(UIScrollView *)sender 
{
   if (self.lastContentOffset > scrollView.contentOffset.y)
   {
       [textField becomeFirstResponder];
   }
   else if (self.lastContentOffset < scrollView.contentOffset.y) 
   {
       [textField resignFirstResponder];
   }
   self.lastContentOffset = scrollView.contentOffset.y;

}

, , ...

0

You need an element such as a UITextView, and then find the scroll (for example, using any of the UIScrollview delegate methods). After scrolling, call the getFirstResponder function in the textView.

0
source

Source: https://habr.com/ru/post/1536085/


All Articles