UICollectionViewController Error in Swift 3.0: must be initialized with a non-nil layout parameter

后端 未结 5 908
清酒与你
清酒与你 2021-01-14 08:03

I\'m new to iOS development. I\'ve been learning Swift, and today, I tried using UICollectionViewController.

My code is as follows:

 class ViewContro         


        
5条回答
  •  深忆病人
    2021-01-14 08:16

    Just change the order like below one :

    let layout = UICollectionViewFlowLayout()
    layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10)
    layout.itemSize = CGSize(width: 90, height: 120)
    colView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
    self.view.addSubview(colView)
    colView.delegate   = self
    colView.dataSource = self
    colView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
    colView.backgroundColor = UIColor.white
    

提交回复
热议问题