Swift:如何在设备旋转后刷新UICollectionView布局
我使用UICollectionView(flowlayout)构建简单的布局。每个单元格的宽度设置为使用self.view.frame.width 但是当我旋转设备时,单元格不会更新。 我找到了一个函数,该函数在方向改变时被调用: override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) { //code } 但我找不到更新UICollectionView布局的方法 主要代码在这里: class ViewController: UIViewController , UICollectionViewDelegate , UICollectionViewDataSource , UICollectionViewDelegateFlowLayout{ @IBOutlet weak var myCollection: UICollectionView! var numOfItemsInSecOne: Int! override func viewDidLoad() { super.viewDidLoad() numOfItemsInSecOne = 8 // Do any additional setup after loading the view, typically from …