views:

110

answers:

1

I have a custom tableviewcell with a label and a textfield. Right now if I click on the cell to edit the textfield, it only focuses on it if I click within the bounds of the textfield. Is there a way for me to click anywhere in the cell and immediately have it focus on the textfield, even if I click on the label?

Thanks

+1  A: 

In your tableView delegate, implement this method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}

Inside that method, get a reference to the selected tableViewCell using - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath and then call becomeFirstResponder on the tableViewCell's textField.

Gotosleep