我已将以下手势识别器添加到我的用户控件中:
UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc]
initWithTarget:self
action:@selector(ViewRotated:)];
[[self view] addGestureRecognizer:rotate];
-(void)ViewRotated:(UIRotationGestureRecognizer *)sender{
NSLog(@"rotated");
}
到目前为止,一切都运行良好,只要我在iOS设备上旋转手指,手势就会快速响应。
现在,在将捏合手势识别器添加到同一视图时会出现问题。当我添加:
UIPinchGestureRecognizer* pch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(ViewPinched:)];
[[self view] addGestureRecognizer:pch];
//...
// ...
-(void)ViewPinched:(UIPinchGestureRecognizer *)sender{
NSLog(@"Pinched");
}
pch事件在70%的时间内触发。我必须以完美的方式旋转我的手指,以便旋转手势而不是捏手势。如何使旋转手势更加合理,以便更容易触发?
答案 0 :(得分:4)
您可以设置手势识别器的委托,并从YES
方法返回gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
。这允许多个手势识别器同时工作。