Reputation: 6450
I want to achieve the following with auto layout.
---------------------
| |
| |
| |
| ScrollView |
| |
| |
| |
| |
---------------------
| |
| Content |
| |
---------------------
The ScrollView
has a width equal to the screen size and the content inside the ScrollView
extends the screen. I do not want the user to be able to scroll horizontally.
I have tried
Put a View
inside of the ScrollView
and set both of them to have leading, trailing, top, and bottom constraints to 0. Then I try to dynamically set the width of the Content and ScrollView
to the ScreenSize.
Simply surround my page's content in a ScrollView
set it to have leading, trailing, top, and bottom constraints to 0. Then I try to dynamically set the width of the ScrollView
to the ScreenSize.
Both of the following result in something like this...
Notice how everything is centered horizontally like I have set it up to be, yet the horizontal scrollbar is present and you can scroll into a blank screen.
Upvotes: 2
Views: 1888
Reputation: 1807
You probably set the wrong content size for the scrollview and hence it is scrolling horizontally.
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, sizeOfContent);
Upvotes: 2