user2363025 user2363025 - 6 months ago 44
Swift Question

scrollView not scrolling swift

I have a scroll view which is not scrolling. Googling seems to indicate that it may be to do with my constraints?

My constraints are as follows:

Trailing space to superview = -16
Leading space to superview = -16
Top space to top layout guide = 0
Bottom space to bottom layout guide = -13

I am printing out the scrollview contentSize in the viewDidLayoutSubViews and it is printing out the same value each time i.e:

scrollview is (375.0, 356.5)

Any idea what the issue may be


Check the bottom constraints of the content view (container inside ScrollView) in your case it's the UILabel

Apple Technical Note TN2154: UIScrollView And Autolayout

To size the scroll view’s frame with Auto Layout, constraints must either be explicit regarding the width and height of the scroll view, or the edges of the scroll view must be tied to views outside of its subtree.

Useful article : Using UIScrollView with Auto Layout in iOS