UIScrollView 禁用仅向一个方向滚动? [英] UIScrollView disable scrolling in just one direction?

查看:40
本文介绍了UIScrollView 禁用仅向一个方向滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直找不到这个问题的答案(也许有人一起破解了一个解决方案).

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

是否可以在一个方向上禁用 UIScrollView 中的滚动?我不是在谈论禁用垂直或水平滚动,而是仅一个方向.例如,在 UIScrollView 中,我希望能够向下拖动滚动视图,但不能向上拖动

Is it possible to disable scrolling in a UIScrollView in one direction? I am not talking about disabling vertical or horizontal scrolling, but one direction only. So for example, in a UIScrollView, I want to be able to drag the scrollview in a downwards direction, but not in an upwards direction

谢谢

推荐答案

事实证明,一个简单的解决方案实际上是可行且容易的:

Turns out a simple solution was actually possible and easy:

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

这篇关于UIScrollView 禁用仅向一个方向滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆