Pan和2 Finger Pinch同步iOS-同时 -

时间:2011-12-06 16:40:23

标签: ios uigesturerecognizer pinch pan simultaneous

2手势识别器:

UIPinchGestureRecognizer *twoFingerPinch = 
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[croppper addGestureRecognizer:twoFingerPinch];

UIPanGestureRecognizer *PanRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)] autorelease];
[croppper addGestureRecognizer:PanRecognizer];

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {        
    return YES;
}   

但同时捏和平底锅不起作用...... 通常我可以捏,因为锅识别器已开启。

问候

2 个答案:

答案 0 :(得分:13)

看起来您没有为每个手势识别器设置委托。 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:是委托方法,因此如果手势识别器没有委托,则不会调用此方法。

因此,默认返回值为NO,因此不会同时识别手势。

答案 1 :(得分:0)

您是否将自己设定为识别者代表?

[twoFingerPinch setDelgate:self];
...
[PanRecognizer setDelegate:self];

PS我也会尝试为你的变量提供更一致的命名方案!