Last active
June 27, 2019 13:55
-
-
Save AlexandrFadeev/4033add8e354d9dbe23f72415ebcdc7a to your computer and use it in GitHub Desktop.
CollectionView layout on device rotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subclass UICollectionViewFlowLayout and overrite this method. | |
- (UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange:(CGRect)newBounds { | |
UICollectionViewFlowLayoutInvalidationContext *context = (UICollectionViewFlowLayoutInvalidationContext *)[super invalidationContextForBoundsChange:newBounds]; | |
context.invalidateFlowLayoutDelegateMetrics = ( | |
CGRectGetWidth(newBounds) != CGRectGetWidth(self.collectionView.bounds) || | |
CGRectGetHeight(newBounds) != CGRectGetHeight(self.collectionView.bounds) | |
); | |
return context; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment