2

Im trying to implement a CollectionView inside my viewController.

And it works just fine.

The problem Im having is that the CollectionView scrolls inside the Parent controller.

I wish to make that if you scroll the collection view - the whole view is scrolled and not just the collection view bit.

I tried disabling scrolling on the Collection View but then nothing is scrolling anymore.

So how would I go about setting the collection view, so that once you scroll on it the whole page scrolls and not just the collection view scrolling inside the parent view controller?

Markwin
  • 177
  • 2
  • 16

1 Answers1

1

It should be simple, and you've done one right thing already.

  1. Disable scrolling of your collectionView (or tableView, in the future just in case you'll use it, they're basically the same).
  2. Add your collectionView (or tableView) inside a scrollView.
  3. That scrollView is of course in your controller's view.
  4. Make sure every constraints are set properly.
  5. You might need to get the size of your collectionView (say height), and set that height value to the constraint height of your collectionView.

These answers of mine in the past should help you:

Voila. The only scrolling enabled is your scrollView that contains your collectionView (or tableView).

Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
  • The problem with this is that giving a specific height to ones collection view will immediately render ALL of the cells - meaning if you have 1000 items in your dataset, all 1000 will render, tanking your devices memory. – Starwave Jan 26 '22 at 21:36
  • @Starwave "meaning if you have 1000 items in your dataset, all 1000 will render, tanking your devices memory." - Nope. That's now how cells work on iOS. – Glenn Posadas Jan 27 '22 at 16:39