gpt4 book ai didi

objective-c - 为什么 requestWhenInUseAuthorization 不提示用户访问该位置?

转载 作者:IT老高 更新时间:2023-10-28 11:26:32 25 4
gpt4 key购买 nike

在我的 viewDidLoad 方法中,我有

locationManager = [[CLLocationManager alloc]init]; // initializing locationManager
locationManager.delegate = self; // we set the delegate of locationManager to self.
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];


if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[locationManager requestWhenInUseAuthorization];
}

并且调用了请求,但是没有提示用户?为什么?

最佳答案

您可能需要更新您的 plist 文件。这是 tutorial how to do it ,又快又脏:

您需要做的是将以下键之一添加到您的 Info.plist 文件中:

NSLocationWhenInUseUsageDescription

NSLocationAlwaysUsageDescription

您还需要为相应的定位方法请求授权,WhenInUseBackground。使用以下调用之一:

[self.locationManager requestWhenInUseAuthorization]
[self.locationManager requestAlwaysAuthorization]

还有一篇我觉得很有帮助的帖子:

Location Services not working in iOS 8

此答案详情how to update your plist file :

Add one of the following lines to your info.plist

<key>NSLocationWhenInUseUsageDescription</key>
<string>The spirit of stack overflow is coders helping coders</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>I have learned more on stack overflow than anything else</string>

您可能需要自定义和拼写检查 info.plist 文件中 shipping the code 之前的字典条目的字符串。 .

关于objective-c - 为什么 requestWhenInUseAuthorization 不提示用户访问该位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31845450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com