Objective c UipAngTestureRecognitor在MKMapView上?

Objective c UipAngTestureRecognitor在MKMapView上?,objective-c,cocoa-touch,mkmapview,uigesturerecognizer,Objective C,Cocoa Touch,Mkmapview,Uigesturerecognizer,我想在用户使用地图视图I移动时添加一些逻辑。E他用平底锅摸。但是,当我添加手势识别器并希望记录触摸时,什么都没有发生。当我在另一个视图控制器中尝试它并将识别器添加到控制器的视图中时,它工作正常 下面是我的代码(map view是application delegate的一个属性,因为即使它不可见,我也需要用它做一些其他事情): 我使用最新的iOS 4.2.1 谢谢你的建议。好吧,因为没人知道,我不得不花一次时间咨询苹果的技术支持;o) 因为MKMapView显然有自己的识别器与用户交互,所以您必

我想在用户使用地图视图I移动时添加一些逻辑。E他用平底锅摸。但是,当我添加手势识别器并希望记录触摸时,什么都没有发生。当我在另一个视图控制器中尝试它并将识别器添加到控制器的视图中时,它工作正常

下面是我的代码(map view是application delegate的一个属性,因为即使它不可见,我也需要用它做一些其他事情):

我使用最新的iOS 4.2.1


谢谢你的建议。

好吧,因为没人知道,我不得不花一次时间咨询苹果的技术支持;o)

因为MKMapView显然有自己的识别器与用户交互,所以您必须遵守UIgestureRecognitizerDelegate协议,并实现
(BOOL)gestureRecognitizer:应与gestureRecognitizer:
同时识别,如下所示:

- (void)viewDidLoad
{
    ...
    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)];
    panGesture.delegate = self;
    [appDelegate.mapView addGestureRecognizer:panGesture];
    [panGesture release];
}

- (void)showPan
{
    NSLog(@"pan!");
}

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

然后,它就像一个符咒。

天哪,谢谢,我花了一段时间才弄明白!重要的是,您仍然可以从UIBuilder定义手势识别器。因此,从技术上讲,重要的是委托方法(如果将识别器定义为iAction,则可以通过ctrl键将其从生成器拖动到showPan),您是否找到了减速的解决方案?当你在中间滚动,你释放,地图继续前进,并放缓。我找不到一个方法来捕捉它。
- (void)viewDidLoad
{
    ...
    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)];
    panGesture.delegate = self;
    [appDelegate.mapView addGestureRecognizer:panGesture];
    [panGesture release];
}

- (void)showPan
{
    NSLog(@"pan!");
}

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