iphone - UIScrollView 一次只向一个方向滚动

标签 iphone ios ipad uiscrollview scroll

我有一个 UIScrollView,我希望它能够在两个方向上滚动(目前是这样),但一次只能滚动一个方向。因此,例如,如果您开始水平滚动它,它根本不会垂直移动,直到您放手并开始垂直移动它。我该怎么做呢?

最佳答案

directionalLockEnabled 属性设置为 YES。来自 Apple 文档:

If this property is NO, scrolling is permitted in both horizontal and vertical directions. If this property is YES and the user begins dragging in one general direction (horizontally or vertically), the scroll view disables scrolling in the other direction. If the drag direction is diagonal, then scrolling will not be locked and the user can drag in any direction until the drag completes. The default value is NO

关于iphone - UIScrollView 一次只向一个方向滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11001938/

相关文章:

iphone - ios 使用 stringWithContentsOfFile 找不到 txt 文件

javascript - 访问 JavaScript 在运行时创建的元素 (document.write)

ios - 字典响应错误

objective-c - 从 CVImageBufferRef 获取内存所有权

ios - 为什么我不能用 Fishhook Hook 我的私有(private)函数

javascript - 为什么 Chrome 会阻止我在网站上的滑动尝试?

iphone - Xcode 显示构建成功,但 iPhone 上未安装应用程序

ios - 如何在OpenGL ES 2.0中实现glOrthof

iphone - Windows Azure 工具包

iphone - 我可以在我的应用程序上使用 Game Center Logo 吗?