How are developers supposed to support interactive reordering of custom cells in UICollectionViews that use UICollectionViewDiffableDataSource?
collectionView.beginInteractiveMovementForItem(at: iPath)
collectionView.updateInteractiveMovementTargetPosition(target)
collectionView.endInteractiveMovement()
Will work maybe 70% of the time, but the other 30% of the time when calling endInteractiveMovement()
the dataSource.snapshot does not properly reflect the updated state.
Obviously there is a way to make this work if we use UICollectionViewListCells and the .reorder accessory, but that's not an acceptable solution.
Please advise.
Update:
dataSource.reorderingHandlers.willReorder = { [weak self] (transaction) in guard let self = self else { return } DispatchQueue.main.async { self.dataSource.apply(transaction.finalSnapshot, animatingDifferences: true) { } } }
This doesn't even work!!!!!!!!!!!!!
The following does work:
dataSource.reorderingHandlers.didReorder = { [weak self] (transaction) in guard let self = self else { return } self.collectionItems = transaction.finalSnapshot.itemIdentifiers(inSection: 0) }
But updating the collection to the proper state after it's supposed to be in the proper state seems wrong. I also find the amount of blinking both solutions incur to be unacceptable.