Hi All, I know that this is a common problem and the UITableViewController fixed this is iPhone SDK 3.0, but the UITableViewController is not working as I expect, probably due to how I am using it. Here's my problem:
I'm working on a form, which is in a grouped table, which contains some text fields. Those on the lower part of the form get obscured by the keyboard. I know this is an age-old problem, and there are some examples of code to auto scroll, but I've a little bit more to add, and was wondering if anyone has found this, and fixed it.
Firstly: Since 3.0, if your table is controlled by a UITableViewController, you get this scrolling automagically. I've tried it and indeed it does work. However, I want to use a custom background image, which UITableViewController doesn't play ball with. Here's what I've done:
- Create the XIB with a plain view, onto which there's an image.
- Also inside the XIB, I've a UIViewController (in fact a my-own subclass as I write the data source methods, etc.), which has the table.
- In my main view viewDidLoadMethod I've tried this: tableViewController.view.backgroundColor = [UIColor clearColor]; [self.view addSubview:tableViewController.view];
And indeed, the table shows up as I expect it to look. However, when I tap on a text field in the table, I'm not getting the "magic" scrolling that the tableViewController is meant to give me for free.
As it stands, it is the exact same behaviour as I didn't use a TableViewController at all, and dropped the table directly onto the imageView. (Which, frankly, makes for 1 less class, and easier to read code).
The only reason I introduced a TableViewController was to get this auto-scrolling.
Is there something I am missing?