ios - 如何阻止iOS应用向上滚动

标签 ios autolayout scrollview

我在 ScrollView 中创建了一个内容 View ,使用 UIScrollView 教程使用常见的自动布局添加了约束。但是当没有内容时如何阻止我的 Scrollview 向上滚动, View 向下滑动到内容,但我想禁用向上滚动,我搜索了答案但没有找到,请帮忙。

最佳答案

能够稍微滚动超出 UIScrollView 中的内容被称为“弹跳”。

The scroll view must know the size of the content view so it knows when to stop scrolling; by default, it “bounces” back when scrolling exceeds the bounds of the content.



您需要将反弹设置为否:

If the value of [bounces] is YES, the scroll view bounces when it encounters a boundary of the content. Bouncing visually indicates that scrolling has reached an edge of the content. If the value is NO, scrolling stops immediately at the content boundary without bouncing. The default value is YES


scrollView.bounces = NO;

关于ios - 如何阻止iOS应用向上滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30220407/

相关文章:

ios - Autorotate 适用于 iOS 6,但在 iOS 5 中会出现奇怪的行为

ios - 访问 UITableView 标题 View

ios - 如何更改最后一个 UITableViewCell 的特定约束?

swift - 添加导航项会缩小 View 中的所有内容

ios - 使用可视格式语言以编程方式将 subview 添加到 ScrollView

ios - 滚动事件后标签文本未更新

ios - iPhone Motion - EXC 访问错误

ios - GPGS 再次在 iOS 32 位设备上崩溃

iOS 自动布局问题

Android ScrollView 弹出窗口不工作