Reputation: 1437
When I do the animations individually everything works fine, but inside of a performBatchUpdates
block the change is instant, almost like I called reloadData()
. Am I using it correctly?
Working method:
NSAnimationContext.currentContext().duration = 0.25
indexPathChanges.map({collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)})
performBatchUpdates
version (instant change - no animation):
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)")
Upvotes: 6
Views: 1220
Reputation: 2796
Try to put it this way:
collectionView.animator().performBatchUpdates({<your animations>}, completionHandler:{finished in <your completion handler>})
In other words, pass it through animator()
proxy.
Upvotes: 9