当询问用户是否要使用位置服务时,应用程序崩溃 [英] Application crashes when asking if user wants to use Location Services

查看:71
本文介绍了当询问用户是否要使用位置服务时,应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用CoreLocation的iPhone应用程序.

I have an iPhone app that is using CoreLocation.

首次安装该应用程序时,会显示iPhone系统消息,询问用户是否要允许位置服务.如果单击是",我的应用程序会突然显示我的应用程序的第一个屏幕(我正在使用导航控制器),然后崩溃.这是我在日志中看到的-

Upon first installing the app, the iPhone system message is displayed asking whether or not the user wants to allow location services, if they click yes, my app suddenly displays the first screen of my app (I'm using a navigation controller), and crashes. This is what I see in the log -

warning: UUID mismatch detected with the loaded library - on disk is:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony
=uuid-mismatch-with-loaded-file,file="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"
Program received signal:  "EXC_BAD_ACCESS".

堆栈跟踪看起来像这样

And the stack trace looks like this

我的代码与LocateMe示例(可在我的设备上运行)相距不远.我有这个:

My code isn't too far off from the LocateMe sample (which works on my device). I have this:

CLLocationManager *clLocationManager = [[CLLocationManager alloc] init];
clLocationManager.delegate = self;

if (clLocationManager.locationServicesEnabled) {
    [clLocationManager startUpdatingLocation];
} else {
    self.searchBar.placeholder = @"Enter location";
}

有什么想法我做错了吗?

Any idea on waht I'm doing wrong?

推荐答案

这似乎是为解决该问题,我总结了此方法

To solve the problem, I wound up following this approach

基本上,在我的ViewController的dealloc方法中-

Basically, in my ViewController's dealloc method -

- (void)dealloc {
locationManager.delegate = nil;
[locationManager release];
}

这篇关于当询问用户是否要使用位置服务时,应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆