UICollectionView Layout Issue

前端 未结 15 1746
天涯浪人
天涯浪人 2020-12-24 00:17

I am using UICollectionView using the flow layout. I have made a custom UICollectionViewCell for the same. But on running the project the console k

15条回答
  •  梦毁少年i
    2020-12-24 00:50

    None of the above fixes did it for me. I fixed it with this

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
    {CGFloat currentWidth = collectionView.frame.size.width;
    UIEdgeInsets sectionInset = [(UICollectionViewFlowLayout *)collectionView.collectionViewLayout sectionInset]; //here the sectionInsets are always = 0 because of a timing issue so you need to force set width of an item a few pixels less than the width of the collectionView.
    
    CGFloat width = currentWidth - 10;
    }
    

提交回复
热议问题