There is an option in IB to uncheck vertical scrolling on a scrollview, but it doesnt seem to work.
How can the scrollview be set to only scroll horizontally, and not vertically in the code rather than IB?
There is an option in IB to uncheck vertical scrolling on a scrollview, but it doesnt seem to work.
How can the scrollview be set to only scroll horizontally, and not vertically in the code rather than IB?
On iOS 11 please remember to add the following, if you're interested in creating a scrollview that sticks to the screen bounds rather than a safe area.:
yes, pt2ph8's answer is right,
but if for some strange reason your contentSize should be higher than the UIScrollView, you can disable the vertical scrolling implementing the UIScrollView protocol method
just add this in your UIViewController
it's just the method called when the user scroll your UIScrollView, and doing so you force the content of it to have always the same .y
since iOS7:
first: the content size width must be equal to the width of your scrollview
second: in your initWithNibName:
That´s it.
I updated the content size to disable vertical scrolling, and the ability to scroll still remained. Then I figured out that I needed to disable vertical bounce too, to disable completly the scroll.
Maybe there are people with this problem too.
Try setting the contentSize's height to the scrollView's height. Then the vertical scroll should be disabled because there would be nothing to scroll vertically.
Include the following method
and set the content size width of the scroll view equal to the width of the scroll view.