iPhone locationManager:禁用 GPS 时出现 didFailWithError 问题

发布于 2024-08-29 15:37:07 字数 1004 浏览 2 评论 0原文

所以,我已经关注了其他相关的线程,但由于某种原因,我仍然遇到这个错误,我准备撕掉我的头发。我已经实现了 locationManager:didFailWithError 来检查用户是否选择“不允许”使用当前位置。

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"IN ERROR");
if ([error code] == kCLErrorDenied){  
 [manager stopUpdatingLocation];
 }
}

但是,当用户选择“不允许”时,总是出现以下错误......这很奇怪,尤其是文本“IN ERROR”出现的顺序。

错误,时间,293420691.000,函数,“无效 CLClientHandleDaemonDataRegistration(__CLClient*, 常量 CLDaemonCommToClientRegistration*, const __CFDictionary*)",服务器没有 接受客户注册1 2010-04-19 21:44:51.000 testApp[1414:207] 错误

因此,它甚至在有机会进入 didFailWithError 函数之前就输出了此错误。有人对可能发生的事情有任何想法吗? locationManager的其余部分代码如下:

self.locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = 2;  
[locationManager startUpdatingLocation];

So, I've followed other related threads, but for some reason I'm still having this error and I'm about ready to tear my hair out. I have implemented locationManager:didFailWithError to check and see if a user selects 'Don't Allow' to use the current location.

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"IN ERROR");
if ([error code] == kCLErrorDenied){  
 [manager stopUpdatingLocation];
 }
}

However, the following error always appears when the user selects 'Don't Allow'...it's strange, especially the order that the text 'IN ERROR' appears.

ERROR,Time,293420691.000,Function,"void
CLClientHandleDaemonDataRegistration(__CLClient*,
const
CLDaemonCommToClientRegistration*,
const __CFDictionary*)",server did not
accept client registration 1
2010-04-19 21:44:51.000
testApp[1414:207] IN ERROR

So, it's outputting this error even before it has a chance to get into the didFailWithError function. Does anyone have any ideas of what might be happening? The rest of the locationManager code is as follows:

self.locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = 2;  
[locationManager startUpdatingLocation];

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

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

发布评论

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

评论(2

A君 2024-09-05 15:37:07

看起来只是来自 Core Location 的信息性消息。它不会使您的应用程序崩溃,用户不会看到它,并且它仍然会使用正确的错误代码调用 didFailWithError 。

在我的测试中,该消息出现在 iPhone 模拟器和设备 (3.1.3) 以及 iPad 模拟器上,但不在 iPad 设备 (3.2) 上。

Looks like just an informational message from Core Location. It's not crashing your app, the user will not see it and it does still call didFailWithError with the correct error code.

In my tests, the message appears on the iPhone simulator and device (3.1.3) and the iPad simulator but not the iPad device (3.2).

故事还在继续 2024-09-05 15:37:07

如果您也使用 MapKit,则这是 MapKit 中的错误。 MapKit 正在向 Core Location 注册,然后无法正确处理用户拒绝位置更新或失败时报告的错误。它应该通过委托方法传递此错误(就像处理地理编码错误一样),但事实并非如此。

不幸的是,我想不出任何方法来拦截来自核心位置的消息,因为 MapKit 维护了一个 CLLocationManager 实例,它用它来获取位置,而这就是向其委托报告错误的实例。

If you're using MapKit as well, this is an error in MapKit. MapKit is registering with Core Location, and then not properly handling the error reported when the user rejects the location update or it fails. It should pass this error on via a delegate method (as it does for geocoding errors), but doesn't.

Unfortunately I can't think of any way to intercept the message from core location, as MapKit maintains an instance of CLLocationManager which it uses to get the location, and that's the one which is reporting the error to its delegate.

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