问题描述
基本上是标题。
如果您使用的是 UICollectionViewDiffableDataSource
,则无法使用传统的 collectionView.beginInteractiveMovementForItem(at: iPath)
方法对单元格重新排序。在 collectionView 上使用“InteractiveMovement”方法需要您实现 collectionView(_:moveItemAt:to:)
,这是一个 UICollectionViewDataSource
协议方法,无法使用,因为我没有使用 UICollectionViewDataSource
,我' m 使用 UICollectionViewDiffableDataSource
。我曾尝试使用传统的“InteractiveMovement”方法使其工作,它们可能在 90% 的时间内工作,但有时它们不起作用,我对此无能为力。
我设法收集到的唯一见解来自 Apple's "Implementing Modern Collection Views",但这完全没用,因为演示代码显示如何支持重新排序的唯一方式是通过
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。
这到底是什么解决方案?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)