6
當我單獨執行動畫時,一切正常,但在performBatchUpdates
塊內部,更改是即時的,幾乎就像我稱爲reloadData()
。我是否正確使用它?NSCollectionView performBatchUpdates不會動畫更改
工作方法:
NSAnimationContext.currentContext().duration = 0.25
indexPathChanges.map({collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)})
performBatchUpdates
版(即時變化 - 不包括動畫):
NSAnimationContext.currentContext().duration = 0.25
collectionView.performBatchUpdates( {
indexPathChanges.map({self.collectionView.moveItemAtIndexPath($0.0, toIndexPath: $0.1)})
// tried this as well - no luck
// indexPathChanges.map({self.collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)})
}, completionHandler: {(finished) in print("Finished: \(finished)")