scroll view not scrolling vertically scroll view not scrolling vertically xcode xcode

scroll view not scrolling vertically


You're using constraints in your scroll view, so the content size is determined by the constraints, not by setting the contentSize in code. You need to fix your constraints so that they size the content from the inside out of the scroll view. The top subview of the scrollview needs to be pinned to the scrollview's top, and the bottom subview needs to be pinned to the scrollview's bottom, and all the views in between need to be pinned to one another, in such a way as to dictate the desired content size height. But the scroll view itself needs to be pinned to its superview, so that it is not taller than the screen. In other words, this will work when the sum of the constrained heights inside the scroll view is greater than the constrained height of the scroll view.


Problem is in constraints. Follow these steps:

Add a container view in scroll view and set top, bottom, leading and trailing constraints of container view with scroll view. Do not set height of this container view. add other views in this container view. Height of container view will adjusted according to sub views of container view. Height of sub views of container view should not set proportional to container view, it should set proportional to scroll view.

Also make sure you have set the top and bottom of container view to its sub view