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

问题描述 投票:7回答:2

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

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

问候

ios uigesturerecognizer pinch pan simultaneous
2个回答
13
投票

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

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


0
投票

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

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

PS我也试图为你的变量获得更一致的命名方案!

© www.soinside.com 2019 - 2024. All rights reserved.