[英]How can I catch the gestures over UICollectionView?
I have a UICollectionView
and a custom UICollectionViewCell
我有一个
UICollectionView
和一个自定义UICollectionViewCell
I want to be able to catch the UICollectionView
gestures as a UIGestureRecognizerDelegate
, actually I want to handle some gestures collisions by using this delegate's method: 我希望能够将
UICollectionView
手势捕获为UIGestureRecognizerDelegate
,实际上我想通过使用此委托的方法来处理一些手势冲突:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
How can I catch the UICollectionView
's UIGestureRecognizerDelegate
? 如何捕获
UICollectionView
的UIGestureRecognizerDelegate
?
UICollectionView
does listen for taps but not by using a UIGestureRecognizer
. UICollectionView
会侦听点击,但不会使用UIGestureRecognizer
。
But you could add your own UIGestureRecognizer
for the type your interested in (like UITapGestureRecognizer
for instance) to the UICollectionView
, set the delegate on it and in gestureRecognizerShouldBegin:
return YES or NO depending on whether you want the UICollectionView
to do it's thing or not, ie returning NO would cancel your gesture and allow the collection view to handle the touches. 但是你可以为你感兴趣的类型添加你自己的
UIGestureRecognizer
(例如UITapGestureRecognizer
)到UICollectionView
,在它UICollectionView
设置委托,在gestureRecognizerShouldBegin:
返回YES或NO,这取决于你是否希望UICollectionView
这样做,即返回NO将取消您的手势并允许集合视图处理触摸。
Or set delayTouchesBegan
to YES if you just want your gestures to take priority over the collection view touch handling. 或者,如果您只是希望手势优先于集合视图触摸处理,请将
delayTouchesBegan
设置为YES。
More info is here Collection View Programming Guide 更多信息在这里收集视图编程指南
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.