如何将两个 UIGestureRecognizer 链接在一起?

发布于 2024-09-13 17:22:48 字数 387 浏览 1 评论 0原文

我想做的是检测滑动手势和平移手势,作为同一触摸序列的一部分。因此,用户首先滑动对象来执行操作,然后在将手指保持在屏幕上的同时向上/向下移动以将操作传播到周围的对象。

我有一个滑动手势识别器和一个平移手势识别器。

在我看来,让它们按照我想要的方式行事的理想方法是这样做:

[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

触ぅ动初心 2024-09-20 17:22:48

您可以通过将滑动和平移设置为同时识别,并对平移进行子类化,以便它实际上将自己标记为已识别,直到识别出滑动为止。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文