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

Phi*_*hil 7 simultaneous pan pinch uigesturerecognizer ios

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];
Run Code Online (Sandbox Code Playgroud)

和:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {        
    return YES;
}   
Run Code Online (Sandbox Code Playgroud)

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

问候

Stu*_*art 13

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

因此,默认返回值将是NO,因此不会同时识别手势.

  • +1正确答案.换句话说,在代码中添加以下两行:`twoFingerPinch.delegate = self;`和`PanRecognizer.delegate = self;`.还要考虑将第二个gestureRecognizer重命名为使用小写首字母. (3认同)
  • 愚蠢的网络缓存 - 现在我的答案看起来很荒谬:( (3认同)