基本上是标题。
如果您使用的是. UICollectionViewDiffableDataSource
,则无法使用 . 的传统方法对单元格重新排序collectionView.beginInteractiveMovementForItem(at: iPath)
。在 collectionView 上使用“InteractiveMovement”方法需要您实现collectionView(_:moveItemAt:to:)
哪个是UICollectionViewDataSource
协议方法,因为我没有使用,所以不能使用UICollectionViewDataSource
,我使用的是UICollectionViewDiffableDataSource
. 我尝试使用传统的“InteractiveMovement”方法使其工作,它们可能有 90% 的时间工作,但有时它们只是不起作用,我对此无能为力。
我设法收集到的唯一见解来自Apple 的“实现现代集合视图”,但这完全没用,因为演示代码显示如何支持重新排序的唯一方法是通过
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Emoji> { (cell, indexPath, emoji) in
var contentConfiguration = UIListContentConfiguration.valueCell()
contentConfiguration.text = emoji.text
contentConfiguration.secondaryText = String(describing: emoji.category)
cell.contentConfiguration = contentConfiguration
cell.accessories = [.disclosureIndicator(), .reorder(displayed: .always)]
}
具体来说,cell.accessories = [.disclosureIndicator(), .reorder(displayed: .always)]
它没用,因为我使用的是不支持添加魔法配件的自定义 collectionviewcell。
这里到底是什么解决方案?