How to disable horizontal scrolling of UIScrollView?

前端 未结 14 1890
伪装坚强ぢ
伪装坚强ぢ 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:59

    I struggled with this for some time trying unsuccessfully the various suggestions in this and other threads.

    However, in another thread (not sure where) someone suggested that using a negative constraint on the UIScrollView worked for him.

    So I tried various combinations of constraints with inconsistent results. What eventually worked for me was to add leading and trailing constraints of -32 to the scrollview and add an (invisible) textview with a width of 320 (and centered).

提交回复
热议问题