-1

I have a UICollectionView build like in the picture. For example, I choose the 5th button and closed and opened the application. I want the 5th button to appear on the screen when the application is opened again. In other words, the UICollectionView should not return to the first position when the application is opened again.

https://i.hizliresim.com/mxX5qT.png

James Bucanek
  • 3,299
  • 3
  • 14
  • 30
  • can you post the image here, instead of giving links? what do you mean by closed and opened the application.? – Harish Mar 05 '20 at 18:51
  • Please show us some code of what you've tried. – Rudedog Mar 05 '20 at 18:52
  • 2
    possible duplicate: https://stackoverflow.com/a/15986085/4757272 use `scrollToIndex(at: IndexPath)` or something like that – Vollan Mar 05 '20 at 18:54
  • You need to save the selected index like 5th and scroll to that cell when you return back to collection view. – RJ168 Mar 05 '20 at 18:57

1 Answers1

-1

You can use this at your collection view's didSelectItem func :

collectionView.scrollToItem(at: indexPath, at: .left, animated: true)

Hope it helps...

hong4rc
  • 3,999
  • 4
  • 21
  • 40
Picode
  • 1,140
  • 1
  • 6
  • 12