OGeek|极客世界-中国程序员成长平台

标题: ios - 检测 MKMapView 何时停止移动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:23
标题: ios - 检测 MKMapView 何时停止移动

每当用户移动我的 MKMapView 时,我都会在 map 上加载更多图钉。现在,我正在使用这段代码来检测他们何时拖动它:

- (BOOL)gestureRecognizerUIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizerUIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

- (void)didDragMapUIGestureRecognizer*)gestureRecognizer {
    if (gestureRecognizer.state == UIGestureRecognizerStateEnded){
        CLLocationCoordinate2D topLeft, bottomRight;
        topLeft = [self.mapView convertPoint:CGPointMake(0, 0) toCoordinateFromView:self.mapView];
        CGPoint pointBottomRight = CGPointMake(self.mapView.frame.size.width, self.mapView.frame.size.height);
        bottomRight = [self.mapView convertPoint:pointBottomRight toCoordinateFromView:self.mapView];

        [self loadMorePlaces:topLeft bottomRight:bottomRight];
    }
}

但是,这只检测用户何时停止拖动。用户可以“ throw ” map ,并且在他们完成“拖动”后 map 仍然可以移动。有什么方法可以找到 map 停止移动的时间吗?谢谢



Best Answer-推荐答案


试试这个委托(delegate):

mapView:regionDidChangeAnimated:

关于ios - 检测 MKMapView 何时停止移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32389078/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4