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.
精彩评论