2016-04-26 77 views
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)") 

回答

2

試圖把它這種方式:

collectionView.animator().performBatchUpdates({<your animations>}, completion handler:{finished in <your completion handler>}) 

在其他窩rds,通過animator()代理。