I am creating a table view with UITextField
s dynamically.
l_textField = [[UITextField alloc] initWithFrame:TextFieldFrame]; l_textField.tag = cellRow; l_textField.delegate = self; l_textField.font = [UIFont boldSystemFontOfSize:14]; l_textField.textColor = [UIColor blackColor]; [l_textField setEnabled:YES]; [cell.contentView addSubview:l_textField];
And now I want to set focus on this text field when user touch cell. I write this
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { UITextField* field = (UITextField *) [tblView viewWithTag: newIndexPath.row]; [field resignFirstResponder]; }
But this doesn't work
change [field resignFirstResponder];
with [field becomeFirstResponder];
resignFirstResponder
is used to remove keyboard (focus) from text field
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With