UICollectionView estimatedItemSize - last cell is not aligned

前端 未结 8 1742
春和景丽
春和景丽 2020-12-29 02:41

I want to make a usual horizontalScrolling flowLayout UICollectionView with estimatedItemSize and preferredLayoutAttributesFittingAttributes in cell. But there is something

相关标签:
8条回答
  • 2020-12-29 02:51

    I face a similar issue and the problem was solved by giving a proper minimum inter item spacing, using the delegate methods - minimumInteritemSpacingForSectionAt- of UICollectionViewDelegateFlowLayout.

    0 讨论(0)
  • 2020-12-29 02:54

    You call super method but you did not use super returned layoutAttributes.

        [super preferredLayoutAttributesFittingAttributes:layoutAttributes];
    

    You can try to print out original layoutAttributes vs super's layoutAttributes. Sometimes, you don't need to call super function.

    Second, You can create custom flowlayout or set inset to let your cell align top. I did this in my project.

    0 讨论(0)
  • 2020-12-29 02:56

    You can consider it a Suggestion. According to me the height of UICollectionView is more than UICollectionViewCell Height, thats why its happening. please make them equal them

    0 讨论(0)
  • 2020-12-29 02:56

    Custom cell size must be same as that of collection view cell,please check that.It may solve the problem for you.

    0 讨论(0)
  • 2020-12-29 02:57

    Had same problem and what fix it in my case was to make sure :

    1. All cells height are equal.

    2. The collectionView height is bigger then cell height + space between cells.

    0 讨论(0)
  • 2020-12-29 03:01

    I have done the similar small project (one raw (1*N) horizontal collection view), here is the github. I hope it would be helpful for your requirement.

    https://github.com/texas16/HorizontalCollectionView

    0 讨论(0)
提交回复
热议问题