I have UITableView that has custom cells representing a player. When I add a new player a new data item is added and [UITableView reloadData] is called. Part of the cell is a UITextView that contains the player name. How do I bring up the keyboard for it?
I could use becomeFirstResponder if I had access to the UITextView in the cell but it hasn't actually been created yet. Since reloadData doesn't actually perform the creation of the new cell yet.
Someone else must have solved this before. Any tips on how to make this work would be greatly appreciated.
My code snippet:
-(IBAction)addPlayerPressed:(id)sender {
Player *newPlayer = [Player alloc];
[players addObject:newPlayer];
[table reloadData];
// Scroll to bottom showing the new player location
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:([players count] - 1) inSection:0];
[table scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// cell is always nil :(
PlayerTableCell *cell = (PlayerTableCell *)[table cellForRowAtIndexPath:scrollIndexPath]
[cell.nameField setfirstResponder];
}