UicollectionView: come animare il cambiamento di una cella?
Domanda
- .
-
In uno stato iniziale, la mia vista di raccolta ha tre celle, in una sezione:
cell1
,cell2
ecell3
. -
nello stato successivo, la prima cella cambia e diventa
cell1_bis
.Ha le stesse dimensioni.
.È possibile animare questo cambiamento
cell1 -> cell1_bis
?
Soluzione
Risposta
Procedi in questo modo:
[self.collectionView
performBatchUpdates:^
{
NSIndexPath * whereTheChangeIs = [NSIndexPath indexPathForItem:row
inSection:section] ;
[self.collectionView deleteItemsAtIndexPaths:@[whereTheChangeIs]] ;
[self.collectionView insertItemsAtIndexPaths:@[whereTheChangeIs]] ;
}
completion:^(BOOL finished)
{
// nothing
}] ;
.
domanda
Sfortunatamente, quanto segue non funziona.Bug?
[self.collectionView
performBatchUpdates:^
{
NSIndexPath * whereTheChangeIs = [NSIndexPath indexPathForItem:row
inSection:section] ;
[self.collectionView reloadItemsAtIndexPaths:@[whereTheChangeIs]] ;
}
completion:^(BOOL finished)
{
// nothing
}] ;
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow