简体   繁体   中英

Disable horizontal scrolling in scrollview (xcode 6)

I'm trying to disable the horizontal scrolling from my scrollview but I don't know how to do it. I tried to follow some tutorials and other answers from stackoverflow but it's my first time using scrollview and I'm a little bit lost.

At the moment the scrolling is vertical, which is fine, but I would like to lock the horizontal scroll.

I'm using storyboard in xcode 6.

I tried again with:

CGSize size = CGSizeMake (self.view.frame.size.width, 800.0);
[UIScrollView setContentSize:size]; - ERROR

Error: 'No known class method for selector setContentSize'

Thanks in advance.

You can set the content size to the width of the screen or less in order to stop horizontal scrolling using:

CGSize contentSize = CGSizeMake(self.view.frame.size.width, scrollableHeight);
[myScrollView setContentSize:contentSize];

Write this in the viewDidLoad method in the corresponding file.

Apple documentation

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