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)")
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With