Search code examples
iosobjective-cswiftuiscrollview

I put the UIView inside a scrollview in my iOS app and it does not scroll. What am I doing wrong?


In my storyboard I put the UIScrollView on my UIViewController. Inside I put a UIView with a UIButton, but when I run the app I cannot scroll the UIView. What am I doing wrong?

This is how the hierarchy looks:

enter image description here

and the properties of scroll view:

enter image description here

and the view (which has a bigger size than scrollview) :

enter image description here

How can I make it scrollable?


Solution

  • From your image it's look like you are using autolayout. So to make view scrollable you need to set the constraints to scrollview and its sub view.

    Constraints for scrollview : Top, Trailing, Bottom, Leading and equal width to superview

    Constraints for view(inside scrollview) : Top, Trailing, Bottom, Leading, equal width to superview and height(whatever you want to set).

    After giving these constraints your view will be scrolled.