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
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.