Refreshing Map View (MKMapView) for iPhone development

Ok so i just spent a long time searching how to reload a map view.

It’s quite simple

[map setRegion:map.region animated:TRUE];

The problem i was having was when i was adding annotations i was adding them through a background thread. So if you want to reload a map after adding annotations make sure you are calling it back in the main thread.

//add to your threaded code
[self performSelectorOnMainThread:@selector(reloadMap) withObject:nil waitUntilDone:FALSE];

//create function
-(void) reloadMap
[map setRegion:map.region animated:TRUE];

Hope this helps someone, if it does let me know so i can at least feel like 2.5 hours wasn’t a complete waste :P

You can leave a response, or trackback from your own site.

Leave a Reply