【问题标题】:How to add cell count in UILabel in Objective C如何在Objective C中的UILabel中添加单元格计数
【发布时间】:2017-02-13 05:44:21
【问题描述】:

我是 iOS 新手,我在计算 UITableView 的单元格并将其添加到 UILabel 时遇到问题。 我需要按照图片所示进行操作

如图所示,计数为 1,2,3,4。有人这样做过吗。在此先感谢!

【问题讨论】:

  • cell count 是行索引加一,因为索引是从零开始的。 (indexPath.row + 1)

标签: objective-c uitableview uilabel


【解决方案1】:

在您的cellForRowAtIndexPath 中,您只需设置单元格的UILabel,如下所示:

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

【讨论】:

  • 很高兴它有帮助,编码愉快!
【解决方案2】:

Xcode 8.0 中

cell.countLabel.text =[nsstring stringwithformate:@"%d",indexpath.row+1];

【讨论】:

    猜你喜欢
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多