开发者

Touch and Tap gestures recognition simultaneously with UIGestureRecognizer

Is it possible to handle Touch and开发者_Python百科 Tap gestures recognition simultaneously with UIGestureRecognizer?


I don't know what kind of recognizer you mean with touch, but i suppose you mean something like pan. But yes, it is possible, simply by creating multiple gesturecognizers. Example:

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[self.view addGestureRecognizer:tapRecognizer];
[self.view addGestureRecognizer:panRecognizer];

I'm assuming you know the basics of gesturerecognizers. If not, i'll be happy to give you a link to a tutorial and help you with any additional questions. However, if they both use the same kind of gesture (like pan and swipe, or a single and double tap recognizer), you will need to use requiresgesturerecognizertofail.


You can use touch methods and gestures as long as you set cancelsTouchesInView to NO on the gesture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜