2012-08-24 154 views
2

我有一個UIScrollViewUIView。我在pagingEnabled模式下使用我的UIScrollView。我不想讓用戶同時雙向滾動。我的意思是,如果用戶開始水平滾動,我想禁用垂直滾動,反之亦然。我怎麼能做到這一點?如何在用戶水平滾動時禁用垂直滾動?

謝謝。

回答

6

嘗試使用UIScrollView的

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 
財產directionalLockEnabled