2014-09-27 87 views
-1

我有一個應用程序想獲取用戶位置。正如你可能知道,蘋果改變用戶的私人政策(如我建議),現在我無法獲得用戶的位置。它顯示沒有錯誤,沒有警告,什麼都沒有。在嘗試調用[_locationManager startUpdatingLocation]; 之前解決這個我添加以下代碼在那裏,它是:iOS 8中破解的位置服務

CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus]; 

    if (authStatus == kCLAuthorizationStatusNotDetermined) { 
     [_locationManager requestWhenInUseAuthorization]; 
     NSLog(@"Case 1"); 
     return; 
    }; 

    if (authStatus == kCLAuthorizationStatusDenied || authStatus == kCLAuthorizationStatusRestricted) { 
     // show an alert 
     NSLog(@"Case 2"); 
     return; 
    }; 

和輸出是情況1,這意味着 - authStatus == kCLAuthorizationStatusNotDetermined。 但沒有提醒,沒有提示,沒有建議用戶啓用我的應用程序的位置服務。實際上,我甚至在我的iPhone設置中手動打開它。仍然不工作(它在Xcode更新之前完美工作)。

如何解決這個問題? 任何意見,將不勝感激,謝謝!

+0

您應該始終調用'requestWhenInUseAuthorization'來移除if語句。另外,您是否已將所需的密鑰添加到您的info.plist中? – Paulw11 2014-09-27 21:32:05

+0

[Xcode 6 GM - CLLocationManager]可能的重複(http://stackoverflow.com/questions/25844430/xcode-6-gm-cllocationmanager) – 2014-09-27 21:52:29

+0

在http://datacalculation.blogspot.in/2014/11找到描述性解決方案/how-to-fix-cllocationmanager-location.html – 2014-11-02 17:19:27

回答

3

您需要在您的info.plist中添加推理,以瞭解您爲什麼要請求用戶位置。

打開info.plist添加一行的密鑰NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription,一種字符串,以及爲什麼要請求用戶位置的值類型。例如,「使用位置來計算日出和日落」。除非你給出了你爲什麼要求它的理由,否則iOS不會要求用戶使用他們的位置。

+0

感謝TyloBedo的幫助! – 2014-09-28 07:17:10

+0

欲瞭解更多描述,你可以訪問http://datacalculation.blogspot.in/2014/11/how-to-fix-cllocationmanager-location.html – 2014-11-02 17:20:27