mapView上的EXC_BAD_ACCESS

时间:2010-11-02 16:03:06

标签: iphone mapkit core-location

当我运行我的地图应用程序时,我收到此错误和EXC_BAD_ACESS ...任何想法

#0  0x3510741c in objc_msgSend ()
#1  0x30a69364 in -[CLLocationManager onClientEventLocation:] ()
#2  0x30a66960 in -[CLLocationManager onClientEvent:supportInfo:] ()
#3  0x30a66b28 in OnClientEvent ()
#4  0x30a5f860 in CLClientInvokeCallback ()
#5  0x30a633e4 in CLClientHandleDaemonData ()
#6  0x357a902c in __CFMessagePortPerform ()
#7  0x3577be46 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8  0x3577be04 in __CFRunLoopDoSource1 ()
#9  0x3576e0a4 in __CFRunLoopRun ()
#10 0x3576dd7a in CFRunLoopRunSpecific ()
#11 0x3576dc88 in CFRunLoopRunInMode ()
#12 0x336ace8c in GSEventRunModal ()
#13 0x318f0f94 in -[UIApplication _run] ()
#14 0x318ee4d4 in UIApplicationMain ()
#15 0x0000281c in main (argc=1, argv=0x2ffff5e0) at /Users/abcd/Desktop/wataproject/main.m:14

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

@ vivianaranha的方法可能会解决这个问题,但我相信(在遇到这个问题之后)你正在做其他不好的事情。

具体来说,在我的情况下,我设置了mapView.showsUserLocation = YES,因此在引擎盖下mapView将自己连接到CLLocationManager。解决方案是确保我在viewWillDisappear中调用了mapView.showsUserLocation = NO

此外,我发现在您致电mapView.userTrackingMode之前,您必须将mapView.showsUserLocation = YES设置为所需内容。总而言之,你最终会得到这样的结果:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.mapView.userTrackingMode = MKUserTrackingModeFollow;
    self.mapView.showsUserLocation = YES;
    self.mapView.delegate = self;
}

- (void)viewWillDisappear:(BOOL)animated {
    self.mapView.userTrackingMode = MKUserTrackingModeNone;
    self.mapView.showsUserLocation = NO;
    self.mapView.delegate = nil;
    [super viewWillDisappear:animated];
}