Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scroll view not scrolling vertically

I have a scroll view that it not scrolling at all:

enter image description here


enter image description here

enter image description here

    scroll_view_content_a_job.contentSize.height = 1800
    scroll_view_content_a_job.isScrollEnabled = true
like image 357
S.M_Emamian Avatar asked Mar 09 '17 16:03

S.M_Emamian


1 Answers

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.

like image 76
matt Avatar answered Oct 12 '22 04:10

matt