How to Subclass UICollectionViewFlowLayout with Storyboard
objective-c, uicollectionview, uicollectionviewlayout, uistoryboard, xcode
Solution
Objects loaded from the storyboard use `initWithCoder:`, not `init`. Move your setup code there instead, or have a common method that is called from each initialiser.
Problem
I'm using a UICollectionView with Storyboard and trying to subclass the UICollectionViewFlowLayout but it doesn't seem to work. I've created the subclass `CollectionViewFlowLayout` : ``` #import "CollectionViewFlowLayout.h" @implementation CollectionViewFlowLayout -(id)init { NSLog(@"Init of CollectionViewFlowLayout"); if (!(self = [super init])) return nil; self.itemSize = CGSizeMake(250, 250); return self; } @end ``` And in the Storyboard's Identity Inspector I changed the class for the flow layout: But when I save/build/run, the itemSize is not set at 250 and my NSLog isn't being output. I've seen in examples such as this that you can set the layout in the collectionView controller, but I sort of assumed that wasn't necessary if you set it in the storyboard.