I am relatively new to using XCode interface builder.
When trying to drag a collection view cell onto an empty collection view, the interface builder refuses to do so.
Please have a look at attached screenshot: Am I doing anything wrong?
Note that I can do the same on a storyboard but not on a normal xib file.
You can only add a UICollectionViewCell inside a UICollectionView when working on a Storyboard file. For sure, you must be using a single nib file and that's why it isn't working.
If you wanna use a custom UICollectionViewCell, then you must create a subclass of UICollectionViewCell. When subclassing UICollectionViewCell don't forget to check the box that says "Also create XIB file" beneath the expandable menu of "Subclass of". Now, try to drag a UICollecionViewCell onto the canvas and custom it the way you want.
Another posibility would be using a Storyboard file. Try setting your UICollectionView inside a scene in the storyboard and then drag a UICollectionViewCell inside it. When dragged, create a UICollectionViewCell subclass and assign it to the UICollectionViewCell you dragged previously inside your CollectionView in the Identity inspector.
In either case, don't forget to set the reuse identifier of your UICollectionViewCell in the Attributes inspector :)
Here is a code sample from Apple of how to create a UICollectionView with a custom UICollectionViewCell using a storyboard.
https://developer.apple.com/library/ios/samplecode/CollectionView-Simple/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012860
Hope this helps :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With