views:

184

answers:

2

I have a UITableView, which I am controlling from a custom UIViewController. When the user clicks the 'add' button, I add a row to the UITableView with a text field in it, and make it the first responder. The problem is, when the bottom of the table is out of view (or hidden by the keyboard), the UITableView doesn't scroll to bring the text field into view.

UITableViewController does this automatically, but my View Controller can't be a subclass of UITableViewController.

A: 

I found -scrollToRowAtIndexPath:atScrollPosition:animated: and guess this would do what you want.

Thomas Müller
It doesn't, because the `UITableView` is still the height of the whole screen (and covered by the keyboard).
nornagon
Oh, OK, makes sense.
Thomas Müller
+1  A: 
nornagon
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[items count] inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; What do "items" mean here?
imMobile
It's an NSArray.
nornagon