Set focus to UITextField in tableCell Set focus to UITextField in tableCell ios ios

Set focus to UITextField in tableCell

change [field resignFirstResponder]; with [field becomeFirstResponder];

resignFirstResponder is used to remove keyboard (focus) from text field

I've faced the same issue here, even using correctly the [field becomeFirstResponder];.

I also used tags to get the objects I have inside the cell. Your didSelectRowAtIndexPath should look like this to get the right cell:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {    currentRow = indexPath.row;    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];    UITextField *indexField = (UITextField *)[cell viewWithTag:101];    [indexField becomeFirstResponder];}

It worked like a charm for me.

Swift 3


My Code. Take index path of current cell. And get cell of next indexpath.row. And called ** cell1.txtFindings.becomeFirstResponder() **

  if  let textFieldIndexPath = specsListView.indexPath(for: cell){        let newIndexPath = IndexPath(row: textFieldIndexPath.row + 1, section: 0)        if let cell1: SpecsTableViewCell = specsListView.cellForRow(at: newIndexPath) as? SpecsTableViewCell{            cell1.txtFindings.becomeFirstResponder()        }}