【问题标题】:How to distinguish two UITableView having a same custom cell如何区分具有相同自定义单元格的两个 UITableView
【发布时间】:2016-07-15 08:16:38
【问题描述】:

您好,我在一个 UIView 类中有两个 UITableView,并且加载了相同的自定义 UITableViewCell。自定义表格视图单元格包含一个 UITextField。这意味着两个 UITableView 包含相同自定义单元格的 UITextfield。当我选择任何该文本字段时,我如何知道选择了哪个 tableView 的文本字段?请帮帮我..

【问题讨论】:

  • 您可以使用标签来唯一识别单元格。
  • 是的,它的工作。谢谢。

标签: ios objective-c iphone


【解决方案1】:
UITextField *txt = ----;

txt.superView.superview 将为您提供所需的 UITableView 实例。
为了更清楚:

UITableViewCell *cell = txt.superView;   // In your case custom cell
UITableView *yourTable = cell.superView;

【讨论】:

  • 一旦他们改变视图层次结构就会中断。
  • @Desdenova :首先,这不是问题的范围。其次,请解释一下你的观点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-01
  • 1970-01-01
  • 2012-12-27
  • 2018-12-19
相关资源
最近更新 更多