如何将两个 UIGestureRecognizer 链接在一起?
我想做的是检测滑动手势和平移手势,作为同一触摸序列的一部分。因此,用户首先滑动对象来执行操作,然后在将手指保持在屏幕上的同时向上/向下移动以将操作传播到周围的对象。
我有一个滑动手势识别器和一个平移手势识别器。
在我看来,让它们按照我想要的方式行事的理想方法是这样做:
[myPanGestureRecognizer requireGestureRecognizerToSucceed:mySwipeGestureRecognizer];
但是尽管我确信我不是刚刚想象的 requireGestureRecognizerToSucceed: ,但似乎我有。
有没有办法在不继承 UIGestureRecognizer 的情况下实现我想要的目标?
What I would like to do is to detect a swipe gesture followed by a pan gesture as part of the same touch sequence. So the user first swipes an object to carry out an action, then, while keeping their finger on the screen, moves up/down to propagate the action to surrounding objects.
I have a swipe gesture recognizer and a pan gesture recognizer.
It seems to me that the ideal way to make them behave the way I want is to do this:
[myPanGestureRecognizer requireGestureRecognizerToSucceed:mySwipeGestureRecognizer];
But although I was sure that I hadn't just imagined requireGestureRecognizerToSucceed:, it seems I have.
Is there a way to achieve what I want without subclassing UIGestureRecognizer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将滑动和平移设置为同时识别,并对平移进行子类化,以便它实际上将自己标记为已识别,直到识别出滑动为止。
You can do this by setting both the swipe and the pan to recognize simultaneously, and subclassing the pan so that it does actually mark itself as recognized until the swipe has been recognized.