Get indexPath of UITextField in UITableViewCell with Swift

前端 未结 4 1153
庸人自扰
庸人自扰 2021-02-04 08:26

So, I\'m building a Detail View Controller App that presents a Table with a two-part cell: the label and the Text Field.

I\'m trying to retrieve the Text Field value and

4条回答
  •  爱一瞬间的悲伤
    2021-02-04 09:04

    You can use tag property of UITableViewCell

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
            let cell = tableView.dequeueReusableCell(withIdentifier: "UpdateTableViewCell", for: indexPath) as! UpdateTableViewCell
    
            cell.tag = indexPath.row
            cell.setCellData()
    
            return cell
    }
    

    now in UITableViewCell

    func textFieldDidEndEditing(textField: UITextField!){
        let textFieldIndexPath = self.tag
    }
    

提交回复
热议问题