Why won't my Collection View Cells display in the iPhone Simulator?

前端 未结 1 1538
礼貌的吻别
礼貌的吻别 2021-01-27 06:52

I am trying to programmatically create a Collection View with six cells. The iPhone Simulator in Xcode 8 told me that my build was successful. There is still an error t

1条回答
  •  有刺的猬
    2021-01-27 07:36

    In your viewDidLoad() Try:

    viewDidLoad() {
    ibCollectionView.dataSource = self
    ibCollectionView.delegate = self
    }
    

    Add this to the top of your class:

    class FluidIntakeMainMenuViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
    

    You must use these functions in your ViewController class:

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {}
    
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {}
    

    0 讨论(0)
提交回复
热议问题