You can do this entirely using constraints and it’s really easy.
The UIScrollView just needs to understand how much width and space it has inside it. So it needs to have something pinned to the Leading, Trailing, Top & Bottom constraints. Also the width and height of the content needs to be fixed (this does not mean I have to specificy it. I can still use constraints to achieve this.)
- Add a
UIScrollViewand position as required. - Add a
UIViewinside theUIScrollViewfor the content. - Set the
Leading,Trailing,Top&Bottomconstraints of the contentUIViewto be 0. - Add an
Equal Widthconstraint to theUIScrollViewandUIView. This will make it vertically scrolling only. - You now need to set the height of the content
UIView. You can then either specify the height of the content view (blech) or use the height of the controls contained within by making sure the bottom control is constrained to the bottom of the content view.
I did this and it worked a treat.