I have a viewcontroller with 2 CollectionView Controllers.
I would like on rotation that only one of the collection views resize to a custom size while the other re
I've handled this by detecting the orientation change in the setBounds: method. We subclass the UICollectionView and override the setBounds: method (see below). In flowLayoutForGallerySize we create a new UICollectionViewFlowLayout with different spacing and itemSize depending on the size of the collection view.
- (void)setBounds:(CGRect)bounds
{
// detect orientation changes and update itemSize in the flow layout
CGSize oldSize = self.bounds.size;
[super setBounds:bounds];
BOOL wasLandscape = (oldSize.width > oldSize.height);
BOOL nowLandscape = (bounds.size.width > bounds.size.height);
if (wasLandscape != nowLandscape) {
// create a new flow layout object for the new gallery size
self.flowLayout = [self flowLayoutForGallerySize:bounds.size];
// change to the new flow layout
[self setCollectionViewLayout:self.flowLayout animated:NO];
DLog(@"orientation change to %@", NSStringFromCGSize(bounds.size));
}
}