I have a UITableViewController with a grouped static UITableView. I am defining the cells for my static table view on the storyboard. One of the cells has a textfield in it. When this textfield is called, the keyboard pops up, however, the tableview is not automatically resizing like it normally would on a table view controller. So now the keyboard is partially covering the textfield and I can't scroll up.
My understanding is that when you are using a UITableViewController and a tableview, the viewable area should automatically shrink when the keyboard is called. It does work as intended in other parts of my app, just not with this static table view. Does it not work with static tables? Is there something else I am missing? Is there an easy way to solve this?
Thanks
Answer
It has nothing to do with static cells. They should work.
If your controller is already a UITableViewController, check if you used the method viewWillAppear
. If you did, you have to call [super viewWillAppear:YES]
to get the 'automatic behavior' to work.
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES]; // This line is needed for the 'auto slide up'
// Do other stuff
}
This problem turns up easily because the boilerplate code for the controllers don't come with the viewWillAppear
method call and if you define it in your controller, you override it.
Extra Information
Look at this link.
Apple Table View Programming Guide
Note: UITableViewController has new capabilities in iOS 3.0. A table-view controller supports inline editing of table-view rows; if, for example, rows have embedded text fields in editing mode, it scrolls the row being edited above the virtual keyboard that is displayed.... blah....
The important bit
The UITableViewController class implements the foregoing behavior by overriding loadView, viewWillAppear:, and other methods inherited from UIViewController. In your subclass of UITableViewController, you may also override these methods to acquire specialized behavior. If you do override these methods, be sure to invoke the superclass implementation of the method, usually as the first method call, to get the default behavior.
For Swift
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With