【发布时间】:2018-05-22 16:17:22
【问题描述】:
我有一个使用流式布局的UICollectionView。它有两个部分。根据一些用户输入,我将单元格从第一部分移动到第二部分。为了使这个变化动起来,我使用了下面的代码:
let oldIndexPath = self.indexPathForAsset(asset)
self.collectionView.performBatchUpdates({
//change data source
let newIndexPath = self.indexPathForAsset(asset)
self.collectionView.moveItem(at: oldIndexPath, to: newIndexPath)
if self.numberOfCollectionViewSections() == 1 {
self.collectionView.deleteSections([0])
}
}, completion: nil)
单元格从第一秒到第二秒动画效果很好,除了最后一个。当最后一个单元格被移动时,我删除了该部分,deleteSections 没有动画。另外,如果我将完成块传递给performBatchUpdates,它不会被调用。
如何将最后一个单元格移动到第二部分并删除第一部分?
【问题讨论】:
-
嗨,我注意到你确实提到了未调用完成块。我还注意到发生了这种情况(未调用完成块),尤其是当我们在
performBatchUpdates中执行部分关系操作时。我想知道,你有办法解决这个问题吗?谢谢。
标签: ios swift animation uicollectionview