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
This has been an ongoing issue in our app but finally I achieved what I believe to be the best and easiest solution so far. Basically you'll need to remove the parent (base) collection view from the superview when device rotates and then add it again to the superview. If you do it properly the system will even animate it for you! Here's an example:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator);
self.collectionView.removeFromSuperview();
self.collectionView = self.getAFreshCollectionViewInstance();
self.setupCollectionViewFrameUsingAutoLayout();
}
As for the data of the collection view, it works just fine by using the existing data source and this is really efficient when data is loaded from the web.