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

前端 未结 5 2180
再見小時候
再見小時候 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 01:08

    I used your answer @PGDev but I put it in viewWillAppear and it works well for me.

    self.collectionView?.scrollToItem(at:IndexPath(item: yourIndex, section: yourSection), at: .left, animated: false)
    

提交回复
热议问题