How to disable horizontal scrolling of UIScrollView?

前端 未结 14 1940
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 08:17

I have a UIView like iPhone\'s Springboard. I have created it using a UIScrollView and UIButtons. I want to disable horizontal scrolli

14条回答
  •  佛祖请我去吃肉
    2020-12-02 08:41

    You have to set the contentSize property of the UIScrollView. For example, if your UIScrollView is 320 pixels wide (the width of the screen), then you could do this:

    CGSize scrollableSize = CGSizeMake(320, myScrollableHeight);
    [myScrollView setContentSize:scrollableSize];
    

    The UIScrollView will then only scroll vertically, because it can already display everything horizontally.

提交回复
热议问题