Reputation: 25318
I have an UIViewController subclass and an IBOutlet named map to an MKMapView instance.
So far, so great, but sometimes the app crashes without a reason when the view controller triggers the viewDidLoad
method. This is absolutely randomly, but only happens when I created around three instances and then create a new one and push it into a navigation controller (however, I have only one of these view controllers at the same time in the navigation controller stack!).
Here is the code of the viewDidLoad
method:
- (void)viewDidLoad
{
[super viewDidLoad];
[map setDelegate:self];
[map setMapType:MKMapTypeStandard];
[map setShowsUserLocation:YES];
if(area)
self.area = area;
}
The stacktrace shows that it crashes when I call [map setShowsUserLocation:YES];
but only on this line (when I comment it out, it never crashes). Here is the stacktrace:
(Sorry for the picture, but I was too lazy to type it all).
Does anyone knows what happens there an why it crashes?
Upvotes: 0
Views: 666
Reputation: 7483
Try setting [map setShowsUserLocation:NO];
in your viewDidUnload
. I have a similar situation, but I recreate the MKMapView programmatically every time the view reloads, and haven't seen this problem.
Upvotes: 1