SnapLikeCollectionView icon indicating copy to clipboard operation
SnapLikeCollectionView copied to clipboard

Unable to deque the cell when created programatically

Open chaitanya-ramji opened this issue 6 years ago • 1 comments

I do not use storyboards at all and have created my collectionView and my cell programatically. I even registered my cell by using this:

func prepareCollectionView()  {
        dataSource = SnapLikeDataSource<DemoCell>(collectionView: collectionView, cellSize: cellSize)
        dataSource?.delegate = self
        
        collectionView.register(DemoCell.self, forCellWithReuseIdentifier: "cellID")
        collectionView.showsHorizontalScrollIndicator = false
        collectionView.decelerationRate = .fast
        collectionView.backgroundColor = .clear
        collectionView.delegate = dataSource
        collectionView.dataSource = dataSource
        
        dataSource?.items = ["A", "B", "C", "D", "E"]
        
        view.addSubview(collectionView)
    }

However, it always crashes with an error could not dequeue a view of kind: UICollectionElementKindCell with identifier Any help on why this is happening?

chaitanya-ramji avatar Sep 29 '19 11:09 chaitanya-ramji

@chaitanya-ramji Can you share a code of initializing DemoCell?

I think the problem is caused on initializing cell.

kboy-silvergym avatar Nov 19 '19 04:11 kboy-silvergym