I know this is a common problem and the UITableViewController fixed this iPhone SDK 3.0, but the UITableViewController does not work as I expect, possibly due to the way I use it. Here is my problem:
I am working on a form that is in a grouped table that contains some text fields. Those at the bottom of the form are covered by the keyboard. I know this is an old problem, and there are some code examples for auto-scrolling, but I will add a little more, and I was wondering if anyone found this and fixed it.
First: starting with 3.0, if your table is controlled by a UITableViewController, you will automatically scroll through this scroll. I have tried and it really works. However, I want to use a custom background image with which the UITableViewController does not play the ball. Here is what I did:
- Create an XIB with a simple view that has an image.
- Also inside XIB, I have a UIViewController (actually my subclass when I write data source methods, etc.) that has a table.
- In my main view, viewDidLoadMethod I tried this: tableViewController.view.backgroundColor = [UIColor clearColor]; [self.view addSubview: tableViewController.view];
And indeed, the table appears, as I expect it to look. However, when I click on a text field in a table, I don't get the “magic” scroll that tableViewController should use to give me free.
In its current form, this is the same behavior that I did not use the TableViewController at all, and dropped the table directly onto imageView. (Which, frankly, makes for 1 smaller class and easier to read code).
The only reason I introduced the TableViewController is autoscrolling.
Is there something I am missing?
source share