UICollectionView : how to animate the change of a cell?
Question
In a initial state, my collection view has three cells, in one section :
cell1
,cell2
andcell3
.In the next state, the first cell change and becomes
cell1_bis
. It has the same size.
Is it possible to animate this change
cell1 -> cell1_bis
?
Solution
Answer
Proceed this way:
[self.collectionView
performBatchUpdates:^
{
NSIndexPath * whereTheChangeIs = [NSIndexPath indexPathForItem:row
inSection:section] ;
[self.collectionView deleteItemsAtIndexPaths:@[whereTheChangeIs]] ;
[self.collectionView insertItemsAtIndexPaths:@[whereTheChangeIs]] ;
}
completion:^(BOOL finished)
{
// nothing
}] ;
Question
Unfortunately, the following does not work. Bug?
[self.collectionView
performBatchUpdates:^
{
NSIndexPath * whereTheChangeIs = [NSIndexPath indexPathForItem:row
inSection:section] ;
[self.collectionView reloadItemsAtIndexPaths:@[whereTheChangeIs]] ;
}
completion:^(BOOL finished)
{
// nothing
}] ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow