admin管理员组文章数量:1318572
I'm having trouble implementing a smooth drop animation when reordering cells in my UICollectionView.
Currently, when I drop an item into a new position, the original cell at sourceIndexPath briefly appears as the moved cell for about half a second before updating correctly.
I tried to remove coordinator, put it before the batch update, after the batch update and also in the completion block. Nothing resolves the problem Screenshot of the bug
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: any UICollectionViewDropCoordinator) {
guard let item = coordinator.items.first,
let sourceIndexPath = item.sourceIndexPath,
let destinationIndexPath = coordinator.destinationIndexPath
else { return }
let url = FSM.pinnedURLs[sourceIndexPath.item]
collectionView.performBatchUpdates({
FSM.movePinnedURL(url: url, position: sourceIndexPath.item, newPosition: destinationIndexPath.item)
collectionView.deleteItems(at: [sourceIndexPath])
collectionView.insertItems(at: [destinationIndexPath])
}, completion: {_ in
coordinator.drop(item.dragItem, toItemAt: destinationIndexPath)
})
}
本文标签: swiftCollectionview drop animation bug when reordering cellsStack Overflow
版权声明:本文标题:swift - Collectionview drop animation bug when reordering cells - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047188a2417856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论