如何在TableView单元格上打印索引号?

时间:2019-02-27 03:21:39

标签: swift uitableview indexing

我想根据存在的表格单元格的数量来打印表格单元格的数量,所以如果有15个单元格,则要打印。第一个单元格应为1,第15个单元格应为状态15。我希望在已打印的访存之前打印此单元格。我在下面张贴了我要寻找的图片。

 cell.textLabel?.text = [" Course: ",attr1," : ", attr2].flatMap { $0 }.reduce("", +)

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以尝试:

let text = [" Course: ",attr1," : ", attr2].flatMap { $0 }.reduce("", +)
cell.textLabel?.text = "\(indexPath.row+1) \(text)"

希望这会有所帮助。

相关问题