Reputation: 861
I'm creating a Form with UITableView, I want that when i click over any part of my row, get the focus on the textfield so I can write on it. Right now to focus on the textfield (yellow space) i have to click only over the textfield (see image). Name is the title (not editable)
Thanks a lot
Upvotes: 3
Views: 396
Reputation: 3212
If you set your delegate properly, this is the delegate method which is fired when user click over any rows.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
So, in this method you are going to use becomeFirstResponder method to get the focus.
[yourTextField becomeFirstResponder ];
Upvotes: 0
Reputation: 42
You can make the textbox as "becomefirstreponder" in didselectrow in case you have it in a table view.
Upvotes: 0
Reputation: 7668
Say you have a textField named myTextField
that you want to have focused when selecting the first row in the table.
Do this in your didSelectRowAtIndexPath:
method
if (indexPath.row == 0) {
[myTextField becomeFirstResponder];
}
Upvotes: 5
Reputation: 8309
In -didSelectRowAtIndexPath
of the row, call [correspondingTextField becomeFirstResponder]
;
Upvotes: 1