Alexey Zakevich Alexey Zakevich - 1 month ago 5
Objective-C Question

How to make uiscrollview only vertical scrolling for ios?

I'm trying to make

using this one tutorial

And get the following result

It will be appreciated for any advices or tutorial links. It needs only vertical scrolling


I am sure there must be other ways to do this but a quick fix is :

1.) Create a width constraint on ContentView in Storyborad.

2.) IBOutlet that widthContraint and set its value to the view frame width in viewDidLoad.

Suppose the name of the constraint outlet is contentViewWidthContraint.

contentViewWidthContraint.constant = self.view.bounds.size.width;

Another alternative to do so from Storyboard, is to fix the Contentview width to the view's width from the storyboard or to the Scrollview, if Scrollview already has a Equal width contraint with superview . Add the "Equal Width" contraint from Contentview to either self.view or to Scrollview (if scrollview, already has the width contraint)