UIScrollView disable scrolling in just one direction?

前端 未结 10 1815
暗喜
暗喜 2020-12-13 09:40

I\'ve been unable to find an answer for this (maybe someone has hacked a solution together).

Is it possible to disable scrolling in a UIScrollView in one direction?

10条回答
  •  伪装坚强ぢ
    2020-12-13 10:35

    The above solutions will reset you to zero,zero if the user accidentally scrolls vertically. Try this...

    - (void)scrollViewDidScroll:(UIScrollView *) scrollView {
        if (scrollView.contentOffset.y > 0) {
            [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0)];
        }
    }
    

提交回复
热议问题