SundayMonday
SundayMonday

Reputation: 19727

Trouble scrolling UITableViewCells containing UITextFields

My UITableViewController subclass has a few UITableViewCells containing UITextFields. The textFields are subviews of the cells' contentViews.

The cells are automatically scrolled up when the keyboard would otherwise cover them. However tapping "Next" to stop editing textfield1 and start editing textfield2 does not properly scroll textfield2. In this case textfield2 is still obscured by the keyboard.

Any ideas why tapping "Next" doesn't scroll the tableView?

Upvotes: 0

Views: 430

Answers (1)

Mark Adams
Mark Adams

Reputation: 30846

UITableViewController automatically handles scrolling the table view in response to the UIKeyboard(Will|Did)(Show|Hide) notifications. Since the keyboard is already on screen, the table view isn't notified that it needs to reposition it's content view. You're going to have to automatically reposition the view in response to the text fields changing first responder status.

Consider using -scrollToRowAtIndexPath:atScrollPosition:animated:.

Upvotes: 3

Related Questions