2014-09-20 34 views
1

目前我有一个使用用户当前地理位置的应用程序。Xcode更改我的应用程序的位置服务

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

我不确定这是否是Xcode的问题,我昨晚更新到了6.01,或者是我的代码中的东西。

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

任何想法是什么导致这个问题?有没有人遇到过类似的问题?

下面是我的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"); 
+0

http://stackoverflow.com/questions/25844430/xcode-6-gm-cllocationmanager/25844674#25844674检查此 – 2014-09-20 14:27:21

回答

0

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

1

我没有在你的代码中看到,你在呼唤requestWhenInUseAuthorization。在位置服务工作之前,这是iOS8中要求用户进行授权的要求。

每次启动位置服务时都要在位置管理器上调用它以确保您拥有权限(如果您已经拥有权限或它已被拒绝,它不会执行任何操作)。

相关问题