UIScrollView一次只能向一个方向滚动 [英] UIScrollView scrolling in only one direction at a time

查看:1091
本文介绍了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 属性是的。来自Apple文档:

Set the directionalLockEnabled property to YES. From the Apple docs:


如果此属性为NO,则允许在水平和垂直方向上滚动。如果此属性为YES并且用户开始沿一个大致方向(水平或垂直)拖动,则滚动视图将禁用向另一个方向滚动。如果拖动方向是对角线,则滚动将不会被锁定,并且用户可以向任何方向拖动,直到拖动完成。默认值为NO

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一次只能向一个方向滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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