【发布时间】:2021-06-21 13:59:38
【问题描述】:
我有一个项目列表,它们在列表中按数量降序显示。我按名称对它们进行哈希处理,因此当我更改数量时,它们应该在应用时顺利重新排序。
当我在UICollectionViewDiffableDataSource 上调用apply(snapshot, animatingDifferences: true) 函数时,它不会以流畅的动画对单元格重新排序,而是会闪烁,并且一切都已就位,没有“重新排序”。
struct Item: Hashable {
let name: String
let amount: Int
func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}
// when user taps, I call this
dataSource.apply(makeSnapshot())
【问题讨论】:
-
你的
UICollectionViewDiffableDataSource<SectionType, ItemType>是什么类型的?
标签: ios swift uicollectionview uicollectionviewcompositionallayout uicollectionviewdiffabledatasource