我有一个表格视图,每个单元格中都有一个文本字段。我添加了这样的目标:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customLevelCell") as! LevelTableViewCell
cell.cellTextField.addTarget(self, action: #selector(ViewController.TextfieldEditAction), for: .editingDidEnd)
return cell
}
Run Code Online (Sandbox Code Playgroud)
但发现我无法使用indexpath.row / sender.tag来获取特定的文本字段文本
@objc func TextfieldEditAction(sender: UIButton) {
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何在用户编辑文本字段之一后获取文本。
另外,我如何获取将用于收集它们添加到特定文本字段的文本的indexpath.row或sender.tag。