J'ai une sous-class de UICollectionViewLayout
qui place les cellules dans un cercle. La disposition renvoie YES
pour l'appel shouldInvalidateLayoutForBoundsChange:
En rotation, la cellule dans la position initiale s'estompe et la cellule dans la position finale s'estompe.
En ajoutant le code suivant à ma layout, je peux désactiver les fondus et le cercle des éléments semble simplement tourner avec le changement d'orientation:
- (UICollectionViewLayoutAtsortingbutes *)initialLayoutAtsortingbutesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { return nil; } - (UICollectionViewLayoutAtsortingbutes *)finalLayoutAtsortingbutesForDisappearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { return [self layoutAtsortingbutesForItemAtIndexPath:itemIndexPath]; }
Pourquoi les methods sont-elles appelées à un changement de limite parce que la documentation ne semble pas suggérer qu'elles le font? La documentation semble indiquer qu'ils sont appelés liés à l'insertion et à la suppression d'éléments de la vue de collection.
Y a-t-il un meilleur moyen de désactiver le fondu enchaîné pendant la rotation?
Remarques:
initialLayoutAtsortingbutesForAppearingItemAtIndexPath:
indique que par défaut la méthode returnne nil
mais les appels à super
returnnent des valeurs non nulles. deleteItemsAtIndexPaths:
deleteItemsAtIndexPaths deleteItemsAtIndexPaths:
moveItemAtIndexPath:toIndexPath:
et insertItemsAtIndexPaths:
et aucun d'entre eux n'est frappé pendant la rotation. Les UICollectionViewLayout.h
file UICollectionViewLayout.h
// This set of methods is called when the collection view undergoes an animated transition such as a batch update block or an animated bounds change. // For each element on screen before the invalidation, finalLayoutAtsortingbutesForDisappearingXXX will be called and an animation setup from what is on screen to those final atsortingbutes. // For each element on screen after the invalidation, initialLayoutAtsortingbutesForAppearingXXX will be called an an animation setup from those initial atsortingbutes to what ends up on screen.
qui dit clairement qu'ils sont appelés à des changements de limites. Plutôt que d'enlever / d'insert, "ancien état" et "nouvel état" semble plus précis.