0

I was trying to add a UISTackview in a scrollview. I believe the UIScrollview setup is right as the following screen has scrolled. Please note that it does not have any stackview, I have added a button with big top constraint so that I can see whether the scrollview works or not.

enter image description here

Next, I added the stackview and just added the top, left, right constraint but not bottom constraint like the following image. However, since there is no bottom constraint, the scrollview does not work.

enter image description here

When I added the bottom constraint, it shows the error like the following image because none of the textfields has height constraints.

enter image description here

If I change the distribution to "Fill Equally". The textfields are taking too much blank spaces depending on the screen size.

enter image description here

How can I use the stackview inside the scrollview. I want to use it as I want some of the views hidden based on conditions and claim the space. Any suggestion would be helpful. Thanks

sadat
  • 4,004
  • 2
  • 29
  • 49

1 Answers1

1

Your second image is correct - but you need one more constraint.

Add a constraint from the Bottom of the Stack View to the Bottom of View (its superview), but set it to >= 0

A couple of tips...

  • rename your UI elements... it gets very confusing to refer to elements by default generic names (you have more than one View, for example).
  • give your objects contrasting background colors during development... makes it much, much easier to see the frames.
DonMag
  • 69,424
  • 5
  • 50
  • 86