简体   繁体   中英

UIScrollView issue while scrolling

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

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

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM