【问题标题】:Is it possible to reverse order a tableView? I search a lot for a solution but nothing works是否可以反转 tableView 的顺序?我搜索了很多解决方案,但没有任何效果
【发布时间】:2020-05-25 08:38:50
【问题描述】:

我想离开滚动方向但以反转版本显示我的单元格,我已经为我的单元格使用 reversed()[indexPath.row],并且知道我只需要反转我所拥有的。

----------
label 1
----------
label 2
----------
label 3
----------
empty
----------
empty
----------

scroll direction
   |
   |
   v

想要的结果:

----------
empty
----------
empty
----------
label 3
----------
label 2
----------
label 1
----------
scroll direction
   |
   |
   v

【问题讨论】:

  • 反转你的数据模型。
  • 我同意,但我想 rbaldwin 的意思是 数据源
  • @JoakimDanielson 是的,谢谢 :)。 OP:UITableView 顶部的空单元格有什么作用?

标签: swift tableview cell


【解决方案1】:

从 iOS 13.5 开始,默认情况下,表格视图中会绘制“空”单元格,如果您反转模型,这些单元格将不会显示。为了实现这一点,您需要向单元格提供一些数据,然后将它们呈现为空。

【讨论】:

    【解决方案2】:

    你可以反转你的数据模型,例如var characters: [Character] = ["C", "a", "f", "é"] characters.reverse() print(characters) // Prints "["é", "f", "a", "C"]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      相关资源
      最近更新 更多