0

I was wondering how I could do the following.

I want to have the UICollectionViewCell span the complete width of the screen whilst having a dynamic height that I can adjust with Autolayout. I understand the Autolayout concept for the problem but I am using the following code and it is fixing the height of the cell instead.

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {

    int width = [[UIScreen mainScreen] bounds].size.width - 16;

    return CGSizeMake(width, 180);
}
ORStudios
  • 2,953
  • 7
  • 34
  • 61
  • If you are not planning on using the Flow capabilities of UICollectionView, why not just use UITableView (that typically uses the full width of the screen to begin with)? – DonMag Feb 20 '17 at 17:30
  • http://stackoverflow.com/questions/28161839/uicollectionview-dynamic-cell-height http://stackoverflow.com/questions/25009907/uicollectionviewcell-dynamic-height-with-autolayout http://stackoverflow.com/questions/26143591/specifying-one-dimension-of-cells-in-uicollectionview-using-auto-layout http://stackoverflow.com/questions/17012397/autoresize-uicollectionview-height-to-adjust-to-its-content-size http://stackoverflow.com/questions/30998480/variable-width-height-of-uicollectionviewcell-using-autolayout-with-storyboard –  Feb 20 '17 at 18:01

0 Answers0