UITableView reloadData automatically calls resignFirstResponder

后端 未结 13 1422
天命终不由人
天命终不由人 2020-12-02 22:44

I have this UITableView with custom cells that can get only predefined values, therefore I use a UIPickerView as their inputView. All is jolly good until I edit a field and

13条回答
  •  清歌不尽
    2020-12-02 23:15

    I use beginUpdate and endUpdate After end update, get the cell contains the textfield already has focus then make it first responder

        self.tableView.beginUpdates()
        self.tableView.reloadRows(at: [indexPath], with: .automatic)
        self.tableView.endUpdates()
        let newCell = self.tableView.cellForRow(at: indexPath)
        newCell.textField.becomeFirstResponder()
    

提交回复
热议问题