0

I've a dynamic UITableView that I created in Storyboard. This tableview has many cells containing a UITextField. When I click a Edit button, I want to enable the textfields and make the textfield in the first row of the tableview first responder. Meanwhile in edit mode more fields have to appear.

I'm able to show more fields and I'm able to show the keyboard to start editing the first row. Anyway, when the rows that I add are many, there is an issue: the keyboard appear but the table view scrolls a little bit down and I can't see the first tableview cell... that's annoying.

I tried many solution, but no one is working. For instance, I tried to use the scrollToRowAtIndexPath here:

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    NSIndexPath *indexPath =[NSIndexPath indexPathForRow:0 inSection:0];
    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
Luca Torella
  • 7,974
  • 4
  • 38
  • 48
  • hmmm, hard to say without any screenshot. Please provide some. Meanwhile you should debug the tableview properties contentInset, contentOffset and contentSize to know your circumstances. – Fab1n Aug 30 '12 at 09:46

1 Answers1

0

UITableView is a kind of UIScrollView. So this solution might work for you. Note, in case your UITableView is managed by standard UITableViewController, then the content will be adjusted automatically.

Community
  • 1
  • 1
onegray
  • 5,105
  • 1
  • 23
  • 29