Nested UICollectionViews, AutoLayout and rotation in iOS 8

后端 未结 7 964
青春惊慌失措
青春惊慌失措 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条回答
  •  梦毁少年i
    2021-02-03 16:40

    TheKey's response is correct. However, instead of reloading the data, you may just call

    UICollectionView.collectionViewLayout:finalizeCollectionViewUpdates()
    

    Example:

    override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
            self.collectionView.collectionViewLayout.invalidateLayout()
            self.collectionView.collectionViewLayout.finalizeCollectionViewUpdates()
        }
    

提交回复
热议问题