【问题标题】:Pan and 2 Finger Pinch simultaneous iOS -at the same time-平移和 2 指同时捏合 iOS - 同时 -
【发布时间】:2011-12-06 16:40:23
【问题描述】:

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


    【解决方案1】:

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

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

    【讨论】:

    • +1 表示正确答案。换句话说,将以下两行添加到您的代码中:twoFingerPinch.delegate = self;PanRecognizer.delegate = self;。还可以考虑重命名第二个手势识别器以使用小写首字母。
    • 你的权利!谢谢! (twoFingerPinch.delegate = self;) 我
    • 愚蠢的网络缓存 - 现在我的答案看起来很荒谬:(
    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多