This is proper way to avoid refreshing map on previous view controller:
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
Question
I have a UIViewController
with a MKMapView
inside UINavigationViewController
hierarchy. When I push-and-pop or present-and-dismiss to another view controller, map view refreshes tiles. I would like to avoid refreshing after present-and-dismiss. I have tried:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// ...
MyModalViewController * vc = segue.destinationViewController;
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
// ...
}
But map view stills refresh tiles after dismissing...
Solution 2
This is proper way to avoid refreshing map on previous view controller:
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
OTHER TIPS
Instead of recreating your MyModalViewController every time you do the segue, put the view controller into a lazy-loaded instance variable and use that for the seque. That way it's only set up once and the map won't refresh. You'll still need to do whatever setup and teardown you need each time the vc appears.