Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 8中的位置服务中断_Ios_Objective C_Ios8_Cllocationmanager - Fatal编程技术网

iOS 8中的位置服务中断

iOS 8中的位置服务中断,ios,objective-c,ios8,cllocationmanager,Ios,Objective C,Ios8,Cllocationmanager,我有一个想要获取用户位置的应用程序。 你们可能知道,苹果改变了用户私有政策(正如我建议的),现在我无法获得用户位置。它没有显示错误,没有警告,什么都没有。为了解决这个问题,我在调用[\u locationManager startUpdatingLocation]之前添加了以下代码 这是: CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus]; if (authStatus == kCLAu

我有一个想要获取用户位置的应用程序。 你们可能知道,苹果改变了用户私有政策(正如我建议的),现在我无法获得用户位置。它没有显示错误,没有警告,什么都没有。为了解决这个问题,我在调用
[\u locationManager startUpdatingLocation]之前添加了以下代码
这是:

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==kclauauthorizationstatusnotdetermined
。 但并没有提醒,并没有提示,也并没有建议用户为我的应用程序启用位置服务。事实上,我甚至在iPhone的设置中手动打开它。但仍然不起作用(它在Xcode更新之前工作得很好)

如何解决这个问题?
如有任何建议,将不胜感激,谢谢

您需要在info.plist中添加一个理由,说明您为什么要请求用户位置


Open info.plist添加一行,其键为
nslocationwhenUsageDescription
NSLocationAlwaysUsageDescription
,这是一种字符串类型,并用于“为什么要请求用户位置”中的值类型。例如,“使用位置计算日出和日落”。iOS不会请求用户使用其位置的权限,除非您给出了请求的原因。

在使用授权时,您应该始终调用
requestwhen
,因此请删除if语句。另外,您是否已将所需的密钥添加到info.plist?可能与“查找描述性解决方案”重复,请访问:谢谢您的帮助!有关更多说明,请访问