Skip to content

Unable to deque the cell when created programatically #7

Description

@chaitanya-ramji

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions