NSCollectionView performBatchUpdates不会对更改进行动画处理

Aus*_*tin 6 cocoa swift

当我单独制作动画时,一切都运行正常,但在一个performBatchUpdates区块内,变化是即时的,就像我打电话一样reloadData().我正确使用它吗?

工作方式:

NSAnimationContext.currentContext().duration = 0.25

indexPathChanges.map({collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)})
Run Code Online (Sandbox Code Playgroud)

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)")
Run Code Online (Sandbox Code Playgroud)

And*_*riy 7

试着这样说吧:

collectionView.animator().performBatchUpdates({<your animations>}, completionHandler:{finished in <your completion handler>})
Run Code Online (Sandbox Code Playgroud)

换句话说,通过animator()代理传递它.