简体   繁体   English

TableViewCell 内的 Swift UITextField

[英]Swift UITextField inside TableViewCell

I am using a table view and have a UITextField inside it, but this text field don't detect the click on the cell.我使用的是表格视图,里面有一个 UITextField,但是这个文本字段没有检测到对单元格的点击。 How I can fix this?我该如何解决这个问题?

subclass the uitextfield, in prepareforreuse, set the delegate to nil, in the cellforrowatindexpath in the uitableview/datasource delegate, set the the textfield delegate to self, then implement the tableview methods there.子类 uitextfield,在 prepareforreuse 中,将委托设置为 nil,在 uitableview/datasource 委托的 cellforrowatindexpath 中,将 textfield 委托设置为 self,然后在那里实现 tableview 方法。 to determine which textfield is clicked, index at point functions for tableview in the UITableView header, once you find that point, convert it to NSIndexPath.要确定单击了哪个文本字段,请在 UITableView header 中为 tableview 的点函数索引,一旦找到该点,将其转换为 NSIndexPath。 use that indexpath to find the array value where you store the textfield text values, update that value, then reload the row or the entire tableview and viola, you have your textfield population and working correctly,使用该索引路径查找存储文本字段文本值的数组值,更新该值,然后重新加载行或整个表格视图和中提琴,您的文本字段填充并正常工作,

lastly, show your code, this is very difficult to answer without showing your code最后,显示您的代码,如果不显示您的代码,这很难回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM