Reputation: 742
I am creating my own flowlayout but I am having problems getting the correct collectionViewContentSize
, my data is an array of arrays, 5 arrays an each array have multiple items.
Is this correct numberOfItemsInSection:0
? or do i need check all the arrays to find the array that have more items and then calculate xSize with the items on that section ?
-(CGSize)collectionViewContentSize {
NSInteger xSize = [self.collectionView numberOfItemsInSection:0] * (itemWidth + space); // "space" is for spacing between cells.
NSInteger ySize = [self.collectionView numberOfSections] * (itemHeight + space);
NSLog(@"size %f, %f", xSize, ySize);
return CGSizeMake(xSize, ySize);
}
Thanks.
Upvotes: 0
Views: 3065
Reputation: 742
Anyone wanting to learn how to do this I found this great tutorial From Bryan Hensen
Upvotes: 2
Reputation: 171
You have both axis being set. Typically, you only need to set one axis (the scrolling axis) because the screen edge (or the edge of your collectionView) in the non-scrolling direction will be set for you. OTher than that, yeah, you'll have to go through each array to get a total height.
Upvotes: 0