8

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;
}   

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

问候

4

2 回答 2

14

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

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

于 2011-12-06T16:43:50.807 回答
0

您是否将自己设置为识别器代表?

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

PS我也会尝试为您的变量获得更一致的命名方案!

于 2011-12-06T17:11:43.770 回答