我有一个 UICollectionView
和一个自定义的 UICollectionViewCell
我希望能够将 UICollectionView
手势捕捉为 UIGestureRecognizerDelegate
,实际上我想通过使用此委托(delegate)的方法来处理一些手势冲突:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
如何捕获 UICollectionView
的 UIGestureRecognizerDelegate
?
最佳答案
UICollectionView
会监听点击,但不会使用 UIGestureRecognizer
。
但是您可以为您感兴趣的类型(例如 UITapGestureRecognizer
)添加您自己的 UIGestureRecognizer
到 UICollectionView
,设置委托(delegate)在上面和 gestureRecognizerShouldBegin:
中返回 YES 或 NO,具体取决于您是否希望 UICollectionView
执行此操作,即返回 NO 将取消您的手势并允许 Collection View 处理触摸。
如果您只想让手势优先于 Collection View 触摸处理,则将 delayTouchesBegan
设置为 YES。
关于ios - 如何通过 UICollectionView 捕捉手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28578946/