开发者

MKMapView strange crash when tracking location

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 vi开发者_JAVA百科ewDidLoad];

    [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:

MKMapView strange crash when tracking location

(Sorry for the picture, but I was too lazy to type it all).

Does anyone knows what happens there an why it crashes?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜