How to scroll to a particluar index in collection view in swift

前端 未结 5 2176
再見小時候
再見小時候 2020-12-06 00:35

We have a collection view. I have made a calendar which shows dates horizontally & I scroll dates horizontally. Now on screen I see only 3-4 dates. Now I want to auto sc

5条回答
  •  天命终不由人
    2020-12-06 01:22

    In viewDidLoad of your controller, you can write the code for scrolling to a particular index path of collection view.

    self.collectionView.scrollToItem(at:IndexPath(item: indexNumber, section: sectionNumber), at: .right, animated: false)
    

提交回复
热议问题