简体   繁体   English

如何区分原型表视图单元格?

[英]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.

相关问题 表格视图的自定义原型单元 - Custom prototype cells for Table View 迅速滚动表格视图时,原型单元正在抖动或发抖 - Prototype cells are shaking or shivering when scrolling the table view in swift 如果我将UISwitch控件添加到每个表视图单元格中,如何判断它属于哪个单元格? - If I add a UISwitch control to each of my table view cells, how can I tell which cell it belongs to? 如何在具有约束的自定义单元格视图中对齐不同原型单元格中的标签 - How to align labels in different prototype cells in a custom cell view with constraints 如何在iOS表格视图中设置原型单元格的高度 - How to set the height of prototype cells in an iOS table views 使用另一个视图的分段控制来控制单个表视图的两个原型单元? - Control two prototype cells of a single table view using segmented control of another view? 如何通过容器视图控制器知道使用了哪些单元格? - How to tell which cells are used through a container view controller? 如何判断一个sqlite表视图是否为空? - How to tell if a sqlite table view is empty? 我想在单个表视图中使用来自nib的两个不同的自定义单元格。 两个原型单元具有不同的高度 - I want to use two different custom cells from nib in a single table view. The two prototype cells have different heights 原型单元 - 第一个没有内容视图 - Prototype Cells - First one with no content view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM