xcode CollectionViewController scrollToItemAtIndexPath not working

前端 未结 9 822
故里飘歌
故里飘歌 2021-02-01 03:06

I have created a CollectionView Control and filled it with images. Now I want to scroll to item at a particular index on start. I have tried out scrollToItemA

9条回答
  •  佛祖请我去吃肉
    2021-02-01 03:42

    If you are trying to scroll when the view controller is loading, make sure to call layoutIfNeeded on the UICollectionView before you call scrollToItemAtIndexPath. This is better than putting the scroll logic in viewDidLayoutSubviews because you won't perform the scroll operation every time the parent view's subviews are laid out.

提交回复
热议问题