UICollectionViewDelegateFlowLayout methods not called during rotation

Inside my View Layout collection (subclass of UICollectionViewFlowLayout ) I defined:

 - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { return YES; } 

My expectation is that since the rotation is a change of boundaries, my layout will be recounted. However, when I set a breakpoint at:

 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 

The breakpoint does not start when the screen rotates. Does anyone know why?

+7
ios uikit ios8 uicollectionview
source share
1 answer

CollectionView: layout: sizeForItemAtIndexPath: the method must be implemented in a class that is a CollectionViewDelegate user interface class. Not in a subclass of UICollectionViewLayout. Where did you implement it?

PS. There is no need to use both. If you have your own UICollectionViewLayout class, use layoutAttributesForItemAtIndexPath: instead

+2
source share

All Articles