1

I have UIScrollView and UITextFields which both are done using size classes. The UIScrollview scrolls, but the problem is that when I scroll it scrolls horizontally as well as vertically.

However, I only require vertical scrolling.

https://drive.google.com/file/d/0BwlIXXitbZCiN05EdmI0WF9UWFk/view?usp=sharing

John Parker
  • 53,316
  • 11
  • 128
  • 128
Hilaj
  • 1,826
  • 2
  • 16
  • 26
  • In autolayout you have to insert sub items in scrollview through a container view in ScrollView. Then You have to set equel width constraint for container view with scrollview SuperView Width . Then It may be help you. – abrar ul haq Aug 12 '15 at 05:31
  • http://stackoverflow.com/questions/31819782/scroll-view-size-not-match-with-the-device-screen-in-xcode/31832570#31832570 see this link to set autolayout for scrollview – abrar ul haq Aug 12 '15 at 05:32

3 Answers3

2

Keep width of UIScrollView less then or equal to its parent view width. Then it will stop scrolling vertically.

Megha Pawar
  • 115
  • 1
  • 5
1

Try setting the scroll view width as width of the device screen. It might be helpful.

   //Change the scroll view width with this
   UIScreen.mainScreen().bounds.size.width;
Karlos
  • 1,608
  • 18
  • 36
  • Yes I did it. I set the constraint equal width as view. Then ambiguity problem is cleared. But it scrolls horizontally too. – Hilaj Aug 12 '15 at 05:27
  • Try setting the width equal to width of your Label/TextField. – Karlos Aug 12 '15 at 05:36
1

In the XIB, set the trailing space and leading space to the edges of screen as 0.

After that make sure that width of Content Size of your scroll view is equal to width of the screen.

It will work fine.

Vikas Dadheech
  • 1,604
  • 10
  • 23