UIScrollView disable scrolling in just one direction?

前端 未结 10 1822
暗喜
暗喜 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:14

    An alternative might be:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        if (scrollView.contentOffset.y < 10) {
            scrollView.bounces = NO;
        }
    
        else scrollView.bounces = YES;
    }
    

    But remember that this will only work for the scrollViews, which have a bigger content than their frames.

提交回复
热议问题