I have a UICollectionView and i want to add animation to each cell.
Currently I'm using
for(UICollectionView *cell in collectionView.visibleCells){
//add animation to cell here
}
But that only applies the animation to the visible cells and as soon as i scroll down and the cell is no longer visible the animation stops.
How do i loop through all the cells in the UICollectionView?
I would go about this in a different way, probably. If you want the cells to animate, you could set a property shouldAnimate = YES. Then in your collectionView:cellForItemAtIndexPath: check that property and apply the animation if needed (or remove it).
After setting the property, reload only the visibleCells: [collectionView reloadItemsAtIndexPaths:collectionView.indexPathsForVisibleItems].
Now, since the animation is provided when a cell is requested through the Datasource-Protocol, you also get the animation when you scroll.
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