2014-09-20 33 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中要求用戶進行授權的要求。

每次啓動位置服務時都要在位置管理器上調用它以確保您擁有權限(如果您已經擁有權限或它已被拒絕,它不會執行任何操作)。

相關問題