user1282637
user1282637

Reputation: 1867

Detecting when MKMapView has stopped moving

Whenever the user moves my MKMapView, I load more pins on to the map. Right now, I am using this code to detect when they drag it:

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

- (void)didDragMap:(UIGestureRecognizer*)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];
    }
}

However, this only detects when a user stopped dragging. A user can "fling" the map and the map can still be moving AFTER they finish "dragging". Is there a way I can find when the map stops moving? Thanks

Upvotes: 3

Views: 1169

Answers (1)

francesco.venica
francesco.venica

Reputation: 1721

Try this delegate:

mapView:regionDidChangeAnimated:

Upvotes: 2

Related Questions