Slavic the Slavic
Slavic the Slavic

Reputation: 411

ScrollView isn't resizing properly

I have a ScrollView with vertical scrolling. The reason for the ScrollView is to fit all of my buttons when the orientation changes to landscape.

There are 2 problems that are possibly linked:

Constraints:

Adjust Scroll View Insets is unchecked. Its all in autolayout, no code.

View Controller Example:

enter image description here

What's strange, is that I have other perfectly working scroll views that resize accordingly. When trying to duplicate the process, I kept getting the same results...

Looked around, but haven't been able to find any helpful answers. So any help would be greatly appreciated.

I'll add other information if needed. I'm sure its a simple solution that I keep overlooking -_-

Upvotes: 0

Views: 756

Answers (2)

amedinam
amedinam

Reputation: 26

I think that your "Bottom space to superView (50) in buttons" is ambiguos, I recommend delete it, the other problem is that your contentView doesn't know its real position, try to add "Center X and Y of your contentView with your scrollView".

Upvotes: 0

slushy
slushy

Reputation: 12385

Anchor scroll view leading and width to view's leading and width; anchor top to label1 bottom and bottom to label2 top.

Get rid of the content view (not needed). Add everything to the scroll view.

Anchor button1 center-x to scroll view center-x and top to scroll view top. If you need to give button1 width or height using constraints, do not use the scroll view's width or height; instead, anchor the button's width to the view's width, height to view's height. Subviews of scroll view should not rely on the scroll view to determine their sizes.

Anchor button4 top to button3 bottom, center-x to scroll view center-x; and most importantly, anchor button4 bottom to scroll view bottom (this will stretch the scroll view for you). This will prevent scrolling when scrolling isn't needed.

Upvotes: 1

Related Questions