When I try to put UICollectionCell
to UICollectionView
in Interface Builder I can't put it with unknown reasons. The cell is going to the tools bar without adding to UICollectionView
I am using:
- iOS SDK 6.0
- XCode 4.5.1
- I don't use Storyboard
When I try to put UICollectionCell
to UICollectionView
in Interface Builder I can't put it with unknown reasons. The cell is going to the tools bar without adding to UICollectionView
I am using:
You cannot put
UICollectionViewCell
directly into theUiCollectionView
if you are usingXib
file. Its possible only in storyboard. Add aUICollectionViewCell
into a separate Xib file. Give your class name. Then register either class or xib before the collection view appearsTypically this is done in
viewDidLoad
.This is the implementation of a custom
UICollectionViewCell
with out usingXib
Only UICollectionView inside StoryBoard have UICollectionViewCell inside. If use XIB, create a new XIB with CellName.xib, add CollectionViewCell to it, specify name of UICollectionView custom class. After that use registerNib.
Sample code: https://github.com/lequysang/TestCollectionViewWithXIB
Okay. There is actually a workaround for this, if you really wanted to have the cell in collectionView inside xib file from interface builder:
It will work perfectly.