ios - 为静态 UITableView 单元格设置数据

标签 ios uitableview

我有一个看起来像这样的 UITableView:

enter image description here

如您所见,我在第一个单元格中显示了一个 UIImageView,还有 2 个标签。文本是从代码设置的。这里没问题。

我的问题涉及底部的 4 个单元格,我想为它们动态设置数据,当我这样做时,我无法设置标签和 UIImageView。我的意思是从 cellForRowAtIndexPath 设置所有内容。谁能解释一下我该如何处理这个案例?

最佳答案

对于静态表,您可以为每个单独的单元格创建一个导出,或者通过 indexPath 引用它们 - [self.tableView cellForRowAtIndexPath:indexPath];

从您的布局来看,4 个单元格位于第 1 部分的第 0 - 3 行。

一旦有了指向单元格的指针,就可以像在动态 TableView 中的 cellForRowAtIndexPath 中一样设置它的 textLabel.text 等。

关于ios - 为静态 UITableView 单元格设置数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9621875/

相关文章:

ios - 对于Apple App Store,我可以选择与App store 上已有的应用相同的应用名称吗?

ios - 位于顶部的 UITableView header

ios - loading... iPad 上的应用程序安装卡住了

ios - 从 XIB 加载的 UITableViewCell 定义 Storyboard segue

ios - 创建像 iOS 日历一样的 TableView

ios - swift 3 : -[_SwiftValue mergeType]: unrecognized selector sent to instance

ios - UITableViewController - 下拉表格 View 以显示新的 UIView

ios - 如何根据 UITableView 滚动动态调整 UITableViewCell 的大小?

iphone - iPhone 中的 UITableview 动画?

ios - 加载时在 UITableView 底部添加一个 ActivityIndi​​cator