Ios – How to make uiscrollview only vertical scrolling for ios


I'm trying to make layout inside scrollview using this one tutorial link

And get the following result link

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

Best Solution

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)