The automatic scrolling of the UITableViewController stops taking into account the keyboard when it is displayed from the UISplitViewController

When subclassing a UITableViewController you usually get certain behavior for free. For example, when a text field in the table view becomes the first responder, the view controller automatically scrolls to ensure that the field is fully visible.

However, when the table view controller is the UISplitViewController detail view UISplitViewController , this automatic scrolling no longer takes into account the presence of the keyboard. The table controller will still scroll automatically to keep the text field within the screen, but it will no longer scroll so the field is not covered by the keyboard.

You can verify this yourself by creating a new project using the Xcode Master Detail Application template and replacing the detail view controller with a table view controller that displays cells with text fields in them.

I would like to understand why auto-scrolling stops accounting for the keyboard in this case, and if possible, fix it without trying to automatically duplicate the auto-scrolling feature. By the way, this has nothing to do with redefinition of viewWillAppear (as in some other questions here about automatic scrolling of a table controller).

+6
source share
1 answer

I know him late, but it can help others who have this problem. This also happens to me when I added a text box to a UITableViewCell. I made to remove

superViewWilAppear: animated

in viewWillAppear mode. Thus, the method is as follows:

 -(void)viewWillAppear:(BOOL)animated{ //[superViewWilAppear:animated]; Your rest of code } 

But this is that it removes the automatic scrolling all together, and you need to control the scrolling of the UITableView when the textField starts editing. I don’t know if this problem solved your problem, but it saves you from having to consider the height of the keyboard for different devices and better manage it yourself. Also, I'm not sure if this is the right way to do this, but it worked for me.

0
source

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


All Articles