I started to use AutoLayout for a large project and was positively surprised about it. However, now I have to adjust the project to accommodate for rotation and size classes, an
Thanks to TheEye. I wanted to add this as a comment to their response, but apparently I don't have enough Karma (yet), So consider this an addendum.
I was having the same problem, however the cells in my uicollectionview have an "expanded state" when selected. if the user rotates the device and we call [self.collectionview reloadData]
, any cells that are expanded will lose their state. You can optionally call performBatchUpdates
and force the collection view to layout without losing the state of any cell
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator{
[self.collectionView.collectionViewLayout invalidateLayout];
[coordinator animateAlongsideTransition:^(id context) {
} completion:^(id context) {
//[self.collectionView reloadData];//this works but reloading the view collapses any expanded cells.
[self.collectionView performBatchUpdates:nil completion:nil];
}];
}