Home > Software design >  How do you extend the height of a collection view and not have scrolling, but have scrolling on the
How do you extend the height of a collection view and not have scrolling, but have scrolling on the

Time:11-07

Right now, I have a collection view with scrolling inside a view.

I'd like the collection view's height to expand downward depending on how much content it has and not have any scrolling.

A user would then scroll from the outside view.

The collection view is the last section in the screenshot:

View Controller with collection view inside of the view

I tried using a table view with one cell having a collection view and that did not work.

CodePudding user response:

"I am fairly new to Swift..."

You may want to first spend some time researching different ways to layout UI elements.

Depending on how many "repeating" elements you'll potentially have, you might want to take this approach:

enter image description here

If you'll potentially have many, many "repeating" views (cells), you might be better off using a collection view - with its built-in memory management - using one of these approaches:

enter image description here

Or, possibly a collection view with a Compositional Layout.

In any case, trying to "expand the collection view to show all the cells and then scroll the whole thing" defeats the purpose of using a collection view, and is rarely the appropriate way to go.

  • Related