Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not cast value of type 'UICollectionViewCell'

I use a custom CollectionViewCell in my Storyboard. When I start the app I get this message:

Could not cast value of type 'UICollectionViewCell' to TestProject.CollectionViewCell.

like image 287
coco Avatar asked Aug 23 '15 11:08

coco


1 Answers

The template for a CollectionViewController in Xcode comes with this line of code in viewDidLoad, which changes the specification in your storyboard.

// Register cell classes self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 

Simply delete that line.

In older Swift versions the line is:

// Register cell classes self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 
like image 120
coco Avatar answered Sep 21 '22 18:09

coco