Reputation: 4247
I'm dealing with a strange issue where I cannot wire up UICollectionView when I want to set it up in a custom UIView.
The reason for having it in UIView instead of UIViewController is that I am creating several custom Views and I'm showing only one per time.
Now, the issue I have is that I am able to drag UICollectionView inside my custom UIView nib but I cannot drop any UICollectionViewCell on it. However, when I do the same thing inside a UIView of a UIVIewController, not only that I am able to drop a cell on it - the cell appears by default.
This is what appears when i place collection view inside a view controller:
This is when I add it to a custom UIView
SO my question is, how to add a cell inside a view?
Upvotes: 1
Views: 1654
Reputation: 7260
You can't do this in view's xib file. Create a separate xib file for your cell and register it in collection view:
let cellNib = UINib(nibName: "YourCellNibFileName", bundle: nil)
collectionView.registerNib(cellNib, forCellWithReuseIdentifier: "YourCellIdentifier")
Upvotes: 2