Default UICollectionView layout does not fit iPad split screen
My layout when split screen doesn't account for the width of the split screen.
My custom view respects it (black bar at the top), but whatever is used in autodetect is out of width.
I am handling the rotation with
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
Is there a helper method for handling split view? Am I processing it in layoutSubview
? I would expect a UICollectionView to handle this for us.
In viewWillTransition I am using
guard let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else {
return
}
flowLayout.invalidateLayout()
+4
source to share
2 answers
Yes. This issue still exists in iOS 13 beta 7.
If you are implementing multiple windows and sharing two collection views side by side. The only left window will be correctly positioned (it could be rotated several times).
Add that in the controller's field of view this can be fixed:
override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() collectionViewLayout.invalidateLayout() }
0
source to share