Markwin
Markwin

Reputation: 187

UICollectionView Scrolling the ViewController

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?

Upvotes: 2

Views: 538

Answers (1)

Glenn Posadas
Glenn Posadas

Reputation: 13283

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).

Upvotes: 1

Related Questions