在用户拖动地图时获取 MKMapView 回调?

get MKMapView callbacks as map is being dragged by user?

使用 IOS MapKit,如何在拖动地图本身的过程中获得回调?我知道我可以检测到拖动的开始和结束,但是我想在拖动过程中获得回调。因此,当用户开始拖动时,我会进行一连串的回调,然后当他们的手指仍然向下并且没有松开时中断,然后当他们再次拖动时会出现更多回调。

背景:想要一个触发器在用户移动地图时更新当前地图的中心lat/long。不确定如何控制我的要求的更新率,但是如果有回调函数我不知道它是可配置的吗?

备用问题:如果 MKMapView 开箱即用是不可能的,那么您最好如何推荐我满足我的要求?

您需要实现 MKMapViewDelegate 方法,例如

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; 

或将您的 panGesture 添加到地图

UIPanGestureRecognizer* panRec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didDragMap:)]; 
panRec.delegate = self; 
[self.mapView addGestureRecognizer:panRec];

并且需要实现 pan 委托方法

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