有没有办法检测多个平移手势?
我希望用户能够从每个拇指同时平移,但我不知道如何使用uigesturerecognizer检测它。 我可以同时检测一个水龙头和一个平底锅没有问题。
看来,第二个潘会阻止第一个。
任何帮助表示赞赏。
我通过定义shouldReceiveTouch来解决它:
-(BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if (gestureRecognizer == singleTap) { return YES; } if (gestureRecognizer == pan1 && [touch locationInView:self].x > 160) { return YES; } if (gestureRecognizer == pan2 && [touch locationInView:self].x <= 160) { return YES; } return FALSE; }
和initWithFrame有以下代码:
self.userInteractionEnabled = YES; singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; singleTap.numberOfTapsRequired = 1; [self addGestureRecognizer:singleTap]; [singleTap release]; NSLog(@"tap: %p", singleTap); pan1 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan1:)]; [self addGestureRecognizer:pan1]; NSLog(@"pan1: %p", pan1); pan2 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan2:)]; [self addGestureRecognizer:pan2]; for (UIGestureRecognizer *recognizer in self.gestureRecognizers) { recognizer.delegate = self; } NSLog(@"pan2: %p", pan2);