ioscallbackdrawingmkmapviewhud

Calling a method after drawing a map region with setRegion:animated: in iOS


Is it possible to know when mapView will complete the drawing a map after calling setRegion method?

I show the HUD before calculating region parameters:

[SVProgressHUD showWithStatus:@"Finding"];

MKCoordinateRegion newRegion;

newRegion.center.latitude     = (maxLat + minLat) / 2;
newRegion.center.longitude    = (maxLon + minLon) / 2;
newRegion.span.latitudeDelta  = maxLat - minLat;
newRegion.span.longitudeDelta = maxLon - minLon;

then setting a new region and hiding the HUD:

[self.mapView setRegion:newRegion animated:NO];
[SVProgressHUD dismiss];

But HUD dismisses faster than a new region appears on the map. How to dismiss the HUD after drawing? Is it any callback for setRegion?


Solution

  • MKMapViewDelegate has mapView:regionDidChangeAnimated: that will be called when your MKMapView has moved to the specified region.

    ref: http://developer.apple.com/library/ios/#DOCUMENTATION/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html