I get this error while trying to use a UICollectionView in Swift:
NSInternalInconsistencyException', reason: 'attempt to register a cell class which is not a subclass of UICollectionViewCell ((null))
But I think I'm registering a cell:
ViewDidLoad:
override func viewDidLoad() { super.viewDidLoad() self.collectionView.registerClass(NSClassFromString("CollectionCell"),forCellWithReuseIdentifier:"CELL") }
cellForItemAtIndexPath:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell { var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL", forIndexPath: indexPath) as CollectionCell cell.titleLabel.text="cellText" return cell }
and cell class:
class CollectionCell: UICollectionViewCell { @IBOutlet var titleLabel : UILabel init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder) } }
Any help appreciated
ios objective-c swift uicollectionview uicollectionviewcell
David DelMonte
source share