ios - 更改动态 TableView 中的特定单元格,Swift

标签 ios uitableview

我想更改 TableView 中特定单元格的标签颜色(通过代码)。问题是我想使用一个动态单元格,这导致每个单元格中的每个标签都会改变它们的颜色。这可能吗?我真的很感激一些帮助。这是在带有 Swift 的 xcode 中。

最佳答案

在您的 UITableViewDataSource 中,您可以使用 tableView:cellForRowAtIndexPath: 更新位于特定 indexPath 的单元格,例如

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:YourCellIdentifier forIndexPath:indexPath]
  if ([indexPath isEqual:theSpecificIndexPath]) {
    cell.label.textColor = ...;
  }
}

关于ios - 更改动态 TableView 中的特定单元格,Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35874570/

相关文章:

ios - SwiftUI 上的 NavigationLink 推送 View 两次

ios - backBarButtonItem 不调用操作

ios - 这个 UIImage 数据读取器线程安全吗?

ios - 更改iframe中视频加载的方向

ios - 在segue中添加数据运行时将无法识别SecondViewController类

ios - 以编程方式设置约束的问题 Swift

ios - 在 Swift 中获取按钮单击 UITableView

ios - 使用自动布局通过动画更改桌面 View 框架

iphone - 什么是 -[UITableViewDelegate willDisplayCell :forRowAtIndexPath:] for?

swift - 如何在 tvOS 中将 UITableViewCell 中的 UICollectionViewCell 聚焦?