【问题标题】:how to disable vertical scrolling while user scrolls horizontally ?如何在用户水平滚动时禁用垂直滚动?
【发布时间】:2012-08-19 19:43:26
【问题描述】:

我在UIView 中有一个UIScrollView。我在 pagingEnabled 模式下使用我的UIScrollView。我不想让用户同时双向滚动。我的意思是,如果用户开始水平滚动,我想禁用垂直滚动,反之亦然。我怎样才能做到这一点?

谢谢。

【问题讨论】:

    标签: iphone ios uiscrollview uiscrollviewdelegate


    【解决方案1】:

    尝试使用 UIScrollView 的属性 directionalLockEnabled

     directionalLockEnabled A Boolean value that determines whether
     scrolling is disabled in a particular direction
    
     @property(nonatomic, getter=isDirectionalLockEnabled) BOOL
     directionalLockEnabled Discussion 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
    
     Availability Available in iOS 2.0 and later. Declared In
     UIScrollView.h
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 2020-06-07
      • 2012-04-23
      • 2019-04-23
      • 1970-01-01
      • 2021-11-13
      相关资源
      最近更新 更多