Nested UICollectionViews, AutoLayout and rotation in iOS 8

后端 未结 7 958
青春惊慌失措
青春惊慌失措 2021-02-03 16:20

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

7条回答
  •  生来不讨喜
    2021-02-03 16:40

    I too had the same problem, with the other answers I found that the layout was getting letterboxed. I got closer to what I wanted with this:

     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    
            super.viewWillTransition(to: size, with: coordinator)
            coordinator.animate(alongsideTransition: nil, completion:  { context in
    
                self.collectionView?.collectionViewLayout.invalidateLayout()
                self.collectionView?.collectionViewLayout.finalizeCollectionViewUpdates()
    
            })
    
        }
    

提交回复
热议问题