1

UICollectionViewFlowLayout...

@interface MediumBounce : UICollectionViewFlowLayout
@property (nonatomic, strong) UIDynamicAnimator *animator;
etc

@implementation MediumBounce

-(void)prepareLayout
    {
    [super prepareLayout];
    self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.minimumInteritemSpacing = 0;
    self.minimumLineSpacing = 0;
    self.itemSize = CGSizeMake(92,144);
    self.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }

-(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
    {
    if(self.animator)
    etc etc etc

You have to set the .itemSize...

So I have many collection views, the cell size is 92.144. However on another collection view, cell size is 200.144.

For that one, I just copy the class, name the new class MediumBounce200, and change the line of code that sets the .itemSize to 200.144.

Is there a better way? Can you read the size from the storyboard somehow?

Or perhaps from the collectionVC, can you "reach down" and set that? When?

(Note that the size which you make the cell in the storyboard, I'm pretty sure, actually doesn't matter: the size is set only by the code above in the FlowLayout.)

Fattie
  • 27,874
  • 70
  • 431
  • 719

1 Answers1

0

For question Can you read the size from the storyboard somehow?

There is a way.

  1. Choose the collection view in storyboard probably inside a viewController.
  2. Set the view's runtime attributes in identity inspector -> User Defined Runtime Attributes
dopcn
  • 4,218
  • 3
  • 23
  • 32
  • Hi Dopcn, U.D.R.A are often very useful, but I definitely do not want to use them here, I want to get it straight from the storyboard, how the designer shapes it on storyboard. (BTW for U.D.R.A., here's an example if anyone's wondering http://stackoverflow.com/a/15007600/294884 ) – Fattie Sep 28 '14 at 14:18