[英]How to tell apart prototype table view cells?
Say I have a table view with a single prototype cell in it that contains a stack view. 假设我有一个表格视图,其中有一个包含堆栈视图的原型单元。 I'd like each cell of the table view generated from the prototype cell to have different views in the stack view. 我希望从原型单元生成的表格视图的每个单元在堆栈视图中具有不同的视图。 So, I need to find a way to tell table view cells apart. 因此,我需要找到一种区分表视图单元格的方法。
If the table view had static cells, I could just use the tag property of the cell and populate stack views easily. 如果表视图具有静态单元格,则可以只使用单元格的tag属性并轻松地填充堆栈视图。 Though, using static cells is probably not the best approach since cells are almost identical to each other. 但是,使用静态单元可能不是最佳方法,因为单元几乎彼此相同。
What can I do to populate stack view differently depending on the "row" of the table view cells? 如何根据表视图单元格的“行”以不同的方式填充堆栈视图?
这正是您应该在tableView:cellForRowAtIndexPath:
方法中执行的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.