Set focus to UITextField in tableCell

前端 未结 3 1911
长情又很酷
长情又很酷 2021-02-12 07:21

I am creating a table view with UITextFields dynamically.

l_textField = [[UITextField alloc] initWithFrame:TextFieldFrame];
l_textField.tag = cellRo         


        
3条回答
  •  天涯浪人
    2021-02-12 07:32

    Swift 3

    myTextField.becomeFirstResponder()
    

    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()
            }
    }
    

提交回复
热议问题