UICollectionView scrolling in both directions

前端 未结 5 805
野性不改
野性不改 2020-12-05 07:30

I made a UICollectionView with a vertical scroll.

The width of the cell is more than than the screen width, so I created a customFlowLayout

5条回答
  •  佛祖请我去吃肉
    2020-12-05 08:30

    I'm not sure I've understood your problem.

    But if you have made a custom layout, make sure you have implemented :

    - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath;
    

    and that your layout attributes frame and size are set with correct values for your "large cell" index path.

    Also make sure you have implemented :

    - (CGSize) collectionViewContentSize;
    

    This method returns the contentSize of the collection View. If contentSize.width > youAppFrame.width you should have horizontal scrolling. Same for height and vertical scrolling.

    Also make sure your collectionView allows scrolling and that your layout is prepared correctly using :

    - (void)prepareLayout
    

    By the way, for your layout have you overloaded UICollectionViewLayout or UICollectionViewFlowLayout ?

提交回复
热议问题