I have a UITableViewController with around 20 static cells, some of these cells have UITextFields within them and some are just for selecting with a checkmark. The table is about 1.5 views worth so scrolling is required to get at the lower text fields.
When I click within a textfield at the bottom of the table the keyboard pops up as it should but this then appears over the cell/textfield.
I was under the impression (From Apple docs and elsewhere) that the UITableViewController class handles scrolling of the view automatically when a keyboard appears in any orientation and shifts the tableview up so that the cell is visible, this isn't happening though.
IOS 5.1, iPad Portrait.
Make sure that if you are overriding viewWillAppear that you call
[super viewWillAppear:animated];
If you don't, the Scroll View will not scroll up properly.
Swift
super.viewWillAppear(animated)
I found non of these answers to be correct. After a while, I notice that if you push a controller it won't work ... but if you present it modally.. the table will automatically scroll to the used textfield.
Hope that saves time and stress to anyone.
I ran into this issue myself. I just converted my view controller from a UIViewController to a UITableViewController in addition to adding the [super viewWillAppear:animated]; call, you will need to remove these lines:
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
As they are no longer needed and setDelegate interferes with the keyboard scrolling behavior.
来源:https://stackoverflow.com/questions/11243712/uitableviewcontroller-not-scrolling-view-when-keyboard-appears