iOS版。如何限制UIScrollview滚动到有限的范围? [英] iOS. How do I restrict UIScrollview scrolling to a limited extent?

查看:1641
本文介绍了iOS版。如何限制UIScrollview滚动到有限的范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UIScrollView的左/右滚动上设置限制的最佳方法是什么。我原以为这会很容易,但我的所有尝试都没有成功。

What is the best way to set limits on the left/right scrolling of a UIScrollView. I would have thought this would be easy but all my attempts have been unsuccessful.

所以,要清楚,我需要一个能让我以编程方式限制滚动的解决方案我需要在使用我的应用程序时的范围。这通常是为了响应所显示数据的变化。

So, to be clear, I need a solution that will allow me to programmatically limit the scrolling extent whenever I need to during the use of my app. This will most often be in response to changes in the data being displayed.

谢谢,

Doug

Thanks,
Doug

推荐答案

我采用了在我的重载layoutSubviews方法中放置泛约束的方法。

I went with my approach of placing pan constraints in my overloaded layoutSubviews method.

伪代码:

Calculate criteria for constraining pan
if (pan-constraint-is-met) {

    Calculate pan-limit
    [self setContentOffset:limitedContentOffset];

}

这篇关于iOS版。如何限制UIScrollview滚动到有限的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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