I have created an Photo album using UICollectionView. I want to handle cell size by codding. If it is possible then please provide me the code. Thank you.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To set the collection view cell size, you can use collectionView method sizeForItemAtIndexPath: .
Here is an example:
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)layout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {CGFloat width = (CGRectGetWidth(self.view.frame)/3.0f)-15);
return CGSizeMake(width, (width *1.1f));
// total 4 views displayed at a time;
}
I hope the above code is helpful for you, because I am using that code in our own sample.