I have a problem managing my UICollectionsView with flowlayout and orientation. Basically, the problems happens when I switch to landscape, some of the UICollectionViewCells are missing. They reappear once I start scrolling. It should be able to show all the cell since there is so much more room on the contentSize.
I even tried in my layout:
- (BOOL) shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
return YES;
}
With the same results.
Anyone have any ideas on this problem? I included a image on how my layout is organized and the expected behavior:
To add more details, each of the color coded cells belongs to its own section and I am shifting my 2nd section to the right on orientation change using:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray* attributesToReturn = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes* attributes in attributesToReturn) {
NSIndexPath* indexPath = attributes.indexPath;
if (nil == attributes.representedElementKind) {
attributes.frame = [self layoutAttributesForItemAtIndexPath:indexPath].frame;
} else {
NSString *kind = attributes.representedElementKind;
attributes.frame = [self layoutAttributesForSupplementaryViewOfKind:kind atIndexPath:indexPath].frame;
}
}
return attributesToReturn;
}
It seems the number of items in the layoutAttributesForElementsInRect are completely different in landscape and in portrait.