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
Adding the scrolling logic to viewDidAppear worked for me:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.collectionView?.scrollToItemAtIndexPath(
someIndexPath,
atScrollPosition: UICollectionViewScrollPosition.None,
animated: animated)
}
Adding it to viewDidLoad doesn't work: it gets ignored.
Adding it to viewDidLayoutSubviews doesn't work unless you want to scroll logic calling any time anything changes. In my case, it prevented the user from manually scrolling the item