地图上的地图结果上的UIGestureRecognizer无法移动?

时间:2017-07-21 01:51:21

标签: ios objective-c baidu-map

我正在尝试使用以下代码检测用户何时启动并停止在mapview上拖动:

- (void)viewDidLoad {
    UIPanGestureRecognizer* panRec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didDragMap:)];
    [panRec setDelegate:self];
    [_mapView addGestureRecognizer:panRec];
}

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

- (void)didDragMap:(UIGestureRecognizer*)gestureRecognizer {
    if (gestureRecognizer.state == UIGestureRecognizerStateEnded){
        NSLog(@"drag ended");
    }
}

然而,当UIGestureRecognizer给我我想要的东西时,地图似乎根本不移动。

可能出现什么问题?

1 个答案:

答案 0 :(得分:0)

好吧,我只需要添加这个

panGesture.cancelsTouchesInView = NO;

不确定是否是百度地图错误,因为MKMapView在没有该选项的情况下工作正常。