Xcode10.3 - Xib can't drag & drop UICollectionViewCell

1.2k views Asked by At

Xcode Version : 10.3

I used xib to create a UIView and added a UICollectionView to the UIView.

When I added UICollectionViewCell, it didn't work. Means I can't drag UICollectionViewCell into UICollectionView

The structure I want is like this

UIView(xib) -> UICollectionView(xib) -> UICollectionViewCell(xib)

Of course, I can add UICollectionViewCell with code, but why doesn't it work with xib? Does anyone know the reason?

enter image description here

enter image description here

Thanks

2

There are 2 answers

2
Noor On

You have to add prototype cells in UICollectionView in xib and then change it's class from UICollectionViewCell to your desired custom class.

2
Noor On

@Nullable for your reference please check this gif demo gif to add custom cell in collection view inside xib