swift CollectionView不滚动UIControl?

cuxqih21  于 2023-04-19  发布在  Swift
关注(0)|答案(1)|浏览(105)

我在水平UICollectionView中有从UIControl继承的按钮。我想添加一个行为,以便即使我们在按钮之间进行水平滚动,我的按钮也不会捕获触摸,并且首先滚动捕获UICollectionView

-- UICollectionView
    -- UIControl (button)
    -- UIControl (button)
    -- UIControl (button)

如何才能做到这一点?

laawzig2

laawzig21#

UICollectionView继承自UIScrollView。因此您可以访问;

open var isTracking: Bool { get } // returns YES if user has touched. may not yet have started dragging

open var isDragging: Bool { get } // returns YES if user has started scrolling. this may require some time and or distance to move to initiate dragging

open var isDecelerating: Bool { get } // returns YES if user isn't dragging (touch up) but scroll view is still moving

我将使用这些检查来查看集合是否正在滚动,如果是,则从所有按钮点击返回。

相关问题