Cells not showing in UICollectionView?

I have a UICollectionViewController in a storyboard that is associated with a file called XCollectionViewController.swift , which is a subclass of UICollectionViewController .

My code is as follows:

 super.viewDidLoad() // Register cell classes self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) } override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { //#warning Incomplete method implementation -- Return the number of sections return 4 } override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { //#warning Incomplete method implementation -- Return the number of items in the section return 10 } override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! UICollectionViewCell // Configure the cell return cell } 

I have a reuse identifier for a set of cells, as it is specified in the file.

When I start, I see the background of the CollectionView, but not the 40 cells that I should see. What's wrong?

+5
source share
1 answer

Just delete this line in the viewDidLoad method to display your 40 cells.

 self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 
+7
source

All Articles