且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从行内的文本字段中读取文本,以及如何在表View Row中找到按钮动作

更新时间:2023-10-29 13:53:28

两种策略.

  1. 子类UITableViewCell,为您的textField添加一个属性.然后,在 -tableView:willSelectRowAtIndexPath:中,您可以调用UITableView的 -cellForRowAtIndexPath:来获取单元格.使用添加的属性访问UITextField.

  1. subclass UITableViewCell, add a property for your textField. Then in -tableView:willSelectRowAtIndexPath: you can call UITableView's -cellForRowAtIndexPath: to get the cell. Use the property you added to access the UITextField.

不要子类.当您将UITextField添加到UITableViewCell时,将其tag属性设置为某些唯一标识符.使用与上述相同的策略来获取UITableViewCell,然后使用UIView的 -viewWithTag:

Don't subclass. When you add the UITextField to the UITableViewCell set it's tag property to some unique identifier. Use the same tactic as above to get the UITableViewCell, but then get a pointer to the UITextField by using UIView's -viewWithTag: