I'm trying to use a UIStackView within a UIScrollView and I was hoping someone could point me in the right direction in creating the right constraints because I can't figure out what the problem is.
These are my constraints and ViewController structure.
So DestCont is a UIView that has a fixed height and ContentCont should take up the rest of the space, which could be (and is) larger than the screen so it should be able to scroll.
When I test it out in the simulator, I have the following problem. (Resized it so it would fit in the 2MB cap)
The green is the Root View and the black color is the ScrollView, as you can see, it cuts off the bottom portion of the ContentCont view.
EDIT
I changed the constraints, removed the fixed UIStackView height, but now, it doesn't show the bottom UIView that's in the UIStackView:
I ended up with being fine that just my "ContentCont" UIContainerView will scroll and fixed the switching by using the following tutorial: https://spin.atomicobject.com/2015/09/02/switch-container-views/.
From your screenshot we know that you have set the
StackView
's height constraint equals to theself.view
's height. Then the height is fixed(equal to one screen's height), even though its content view's height may be larger than the screen.And
UIScrollView
will calculate itscontentSize
depending on its content, so in your case itscontentSize
's height will always be one screen heigt.Delete this height constraint, let the
ContentCont
's content decide the height of it. Also please make sure your constrains in yourContentCont
are correct.