UIScrollView scrolling in only one direction at a time(UIScrollView 一次只向一个方向滚动)
问题描述
我有一个 UIScrollView,我希望它能够双向滚动(目前可以),但一次只能滚动一个.因此,例如,如果您开始水平滚动它,它根本不会垂直移动,直到您松开并开始垂直移动它.我该怎么做呢?
I have a UIScrollView and I want it to be able to scroll in both directions (it currently does) but only one at a time. So, for instance, if you start scrolling it horizontally, it won't move vertically at all until you let go and start moving it vertically. How could I go about doing this?
推荐答案
将 directionalLockEnabled
属性设置为 YES.来自 Apple 文档:
Set the directionalLockEnabled
property to YES. From the Apple docs:
如果此属性为 NO,则允许在水平和垂直方向上滚动.如果此属性为 YES 并且用户开始沿一个大致方向(水平或垂直)拖动,则滚动视图将禁用在另一个方向上的滚动.如果拖动方向是对角线,则滚动不会被锁定,用户可以向任意方向拖动,直到拖动完成.默认值为否
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
这篇关于UIScrollView 一次只向一个方向滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView 一次只向一个方向滚动


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01