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
  • 54,048
  • 11
  • 129
  • 129
Hilaj S L
  • 1,936
  • 2
  • 19
  • 31
  • 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,653
  • 18
  • 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,672
  • 12
  • 23