如何链接两个UIGestureRecognizer在一起? [英] How do I chain two UIGestureRecognizers together?

查看:130
本文介绍了如何链接两个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.

在我看来,使他们按我想要的方式行为的理想方式是这样做: p>

It seems to me that the ideal way to make them behave the way I want is to do this:

[myPanGestureRecognizer requireGestureRecognizerToSucceed:mySwipeGestureRecognizer];

但是,虽然我确信我没有想到requireGestureRecognizerToSucceed :,它似乎我有。

But although I was sure that I hadn't just imagined requireGestureRecognizerToSucceed:, it seems I have.

有没有办法实现我想要的没有子类化UIGestureRecognizer?

Is there a way to achieve what I want without subclassing UIGestureRecognizer?

推荐答案

您可以通过同时设置滑动和平移来同时识别,并将泛化子类化,以便它确实将自己标记为已识别,直到识别到滑动。

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.

这篇关于如何链接两个UIGestureRecognizer在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆