您可以添加两种不同UILongPressGestureRecognizers,一个设置了numberOfTouchesRequired
= 1,和一个= 2 你也可能想在一个只有预计,1个手指是否能识别另一个(万一用户发生故障用一根手指敲击,并在放下另一根手指后立即敲击)。
这将是这样的:
UILongPressGestureRecognizer *oneFingerLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerLongPressed:)];
oneFingerLongPressGesture.numberOfTouchesRequired = 1;
UILongPressGestureRecognizer *twoFingersLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersLongPressed:)];
twoFingersLongPressGesture.numberOfTouchesRequired = 2;
[oneFingerLongPressGesture requireGestureRecognizerToFail:twoFingersLongPressGesture];
UIView *someView;
[someView addGestureRecognizer:oneFingerLongPressGesture];
[someView addGestureRecognizer:twoFingersLongPressGesture];
[oneFingerLongPressGesture release];
[twoFingersLongPressGesture release];
是的,这是预期的行为。控件将受到您在启动前指定的触摸量的限制。 – MrShoot 2012-04-17 19:07:59