0

我有一个存在于我的 VM 中的输出,并且基于一些更改,我希望驻留在我的自定义 tableviewCell 中的文本字段以某种方式更改。我不确定如何将位于 tableviewcell 中的 UItextfield 绑定到我的输出。

4

2 回答 2

0

我不确定您何时想要获取数据,但如果您想在用户触摸单元格时执行此操作,只需实现以下方法UITableViewDelegate

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        if let cell  = tableView.cellForRow(at: indexPath) as? YourTableViewCellClass {
        let cellLabelText = cell.yourTextField.text
        // Do whatever you want with cellLabel

        }
    }

于 2019-06-28T16:51:52.583 回答
0
  let index = IndexPath(row: 0, section: 0)
  if let cell  = tbl.cellForRow(at: index) as? TableViewCell {
        print(cell.textF.text)
        // Do whatever you want

  }
于 2019-06-28T16:39:33.363 回答