1

目前我有一个使用用户当前地理位置的应用程序。

每当我在我的设备或模拟器上运行该应用程序时,该应用程序就会打开并立即将我的位置服务从“授权”变为“未确定”。出于某种原因,这只发生在我身上,而我的其他开发人员都没有。

我不确定这是我昨晚更新到 6.01 的 Xcode 的问题,还是我的代码中的问题。

我已经尝试为应用程序重置定位服务,但是当我返回应用程序时,它立即将其更改回“未确定”。

知道是什么导致了这个问题吗?有没有人遇到过类似的问题?

下面是来自我的 locationManager 的一段代码。

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
NSLog(@"did change status");

if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
    NSLog(@"not determined");

} else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) {
    NSLog(@"Authorized");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"Location Services Authorized" object:self];

} else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted){
    NSLog(@"restricted");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"Location Services Restricted" object:self];

} else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
    NSLog(@"denied");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"Location Services Denied" object:self];

} else {
    NSLog(@"can not");
4

3 回答 3

1

我没有在您的代码中看到您正在调用的位置requestWhenInUseAuthorization。在 iOS8 中,这是在定位服务运行之前要求用户授权的必要条件。

每次启动位置服务时只需在位置管理器上调用它以确保您获得许可(如果您已经获得许可或已经被拒绝,它什么也不做)。

于 2014-09-20T17:54:38.987 回答
0

可能是应用程序无法访问位置服务,它应该在设置屏幕中关闭,你能检查一下吗? 继续设置>隐私>定位服务>“您的应用程序”>打开

于 2014-09-20T14:35:44.820 回答
0

我解决了这个问题!

事实证明,Apple 对其核心位置管理器进行了一些更改。

你可以在这里读更多关于它的内容:

http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/

谢谢您的帮助。

于 2014-09-23T17:41:26.907 回答