UIGestureRecognizer on Map results on Map cannot be moved?

60 views Asked by At

I am trying to detect when user starts and stops dragging on mapview with this following code:

- (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");
    }
}

However, the map seem doesn't move at all while the UIGestureRecognizer gives me what I want.

What could be wrong?

1

There are 1 answers

0
Rendy On BEST ANSWER

Well, I only need to add this

panGesture.cancelsTouchesInView = NO;

Not sure is it Baidu Map bug or not since MKMapView works fine without that option.