地图视图上的 EXC_BAD_ACCESS

发布于 2024-09-30 03:41:40 字数 863 浏览 7 评论 0原文

当我运行地图应用程序时,我收到此错误和 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

i get this error and EXC_BAD_ACESS when i run my maps application... any idea

#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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北方的巷 2024-10-07 03:41:40

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

具体来说,在我的例子中,我设置了 mapView.showsUserLocation = YES,因此在幕后,mapView 将自身连接到 CLLocationManager。解决方案是确保我在 viewWillDisappear 中调用了 mapView.showsUserLocation = NO

我还发现,在调用 mapView.showsUserLocation = YES 之前,您必须将 mapView.userTrackingMode 设置为您需要的内容。把它们放在一起,你最终会得到这样的结果:

- (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];
}

@vivianaranha's approach might solve the issue but I believe (after encountering this myself) that you are doing something else bad.

Specifically, in my case I had set mapView.showsUserLocation = YES so under the hood mapView was wiring itself up to the CLLocationManager. The solution was to ensure that I called mapView.showsUserLocation = NO in viewWillDisappear.

Also I discovered that you must have mapView.userTrackingMode set to what you require before you make the call to mapView.showsUserLocation = YES. Putting it all together you end up with something like this:

- (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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文