Why isn't UITableView Autoscrolling when editing a UITextField (in a UITableViewCell)? (Iphone)

I created a UITableView that is of type UITableViewStyleGrouped . Then I created several different sections with several lines in each. On each of these lines, I created a custom UITableViewCell containing a UITextField . I also have one UITableViewCell that contains a UITextView .

I also implemented the UIToolbar , which appears on top of the UIKeyboard , which allows the user to navigate through the UITextField by pressing the previous or next .

The problem I am facing is twofold:

  • I need the UITableView to scroll so that when the next UITextField (or UITextView ) becomes the first responder, it is visible (even with the keyboard displayed).
  • If the UITextField (or UITextView ) option is selected (without using the previous and next buttons), you must adjust it so that the field is visible above the keyboard.

I looked through many different guides, but none of them solved my problem. Any help you could offer would be greatly appreciated.

ADDITIONAL INFORMATION:

I am 100% sure that my application used all of this automatically, but I seem to have stopped doing it now, and I don’t understand why. Is there a reason why this could happen? Is there some kind of function or something that I may have changed that will destroy this behavior?

+4
source share
3 answers

Check out TaggedLocations sample code from apple. He does the same without any additional manipulation.

The key is that your view controllers are compliant. those. You are NOT with container view controllers such as the UINavigationController in the UIViewController.

+4
source

Probably, now you do not need to use the original poster, but those who have such a problem, when he once worked, and then stopped ...

check that you do not have:

 - (void)viewWillAppear:(BOOL)animated 

in a subclass of UITableViewController !!!

using viewWillAppear in a UITableViewController breaks the behavior of the "automagic tableView scrolling up when keyboard appears".

I just found this by comparing the painstakingly old version of the project where he worked with my last source, where he stopped working.

+14
source

You need to update the tableview Frame program yourself ... and I am 100% sure that if you are 100% sure that your application used all this above automatically ... than this is not your application.

Check documents .. no link

https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-W11

You will have to register for keyboard notifications .. and then update the tableview frame. And for the next and previous .. you need to programmatically check which text field has become active .. and then set the frame accordingly.

-5
source

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


All Articles