Question

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?

Was it helpful?

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

OTHER TIPS

– mapViewDidFinishLoadingMap: of MKMapViewDelegate can be used to execute code after loading of the map finished.

[SVProgressHUD performSelector:@selector(dismiss) withObject:nil afterDelay:0.5]; Details in the docs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top