Obj-c - 数字表格单元格降序而不是升序?

Posted

技术标签:

【中文标题】Obj-c - 数字表格单元格降序而不是升序?【英文标题】:Obj-c - Number table cells descending instead of ascending? 【发布时间】:2019-01-31 06:08:50 【问题描述】:

我的单元格中目前有一个 UILabel,它显示从顶部 1 开始的计数 (1, 2, 3, 4...)。但是,我怎样才能使计数下降呢?看起来很简单,但我似乎无法弄清楚。

我当前的代码:

 cell.countLabel.text = [NSString stringWithFormat:@"%ld)", (long)indexPath.row +1];

【问题讨论】:

【参考方案1】:

你可以从 indexpath.row 中减去项目的总数

cell.countLabel.text = [NSString stringWithFormat:@"%ld)", (long)(items.count - indexPath.row)];

【讨论】:

以上是关于Obj-c - 数字表格单元格降序而不是升序?的主要内容,如果未能解决你的问题,请参考以下文章