Inside of my Collection View Layout (a subclass of UICollectionViewFlowLayout
) I have defined:
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES;
}
My expectation is that since rotation is a bounds change, my layout will get recalculated. However when I set a breakpoint in:
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
The breakpoint is not triggered when the screen rotates. Does anyone know why?
The collectionView:layout:sizeForItemAtIndexPath: method should be implemented in the class that is the UI CollectionViewDelegate class. Not in the sub class of the UICollectionViewLayout. Where did you implement it?
PS. There is no need to use both. If you have a custom UICollectionViewLayout class, use layoutAttributesForItemAtIndexPath: instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With