- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是 iOS 应用程序中的一个奇怪行为。这是与我的问题相关的代码:
初始化位置信息:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager requestWhenInUseAuthorization];
当请求位置功能时:
if ([CLLocationManager authorizationStatus]!=kCLAuthorizationStatusAuthorized) {
// Give a message to the user: NO GPS HERE!
}
在 app.plist 中我放置了一个键:NSLocationWhenInUseUsageDescription
,带有一个字符串。
由于某种我不明白的原因,它不起作用。我被告知这个应用程序不允许使用 GPS,我必须更改隐私设置,我去按照要求更改隐私设置,我回来再试一次,并收到相同的消息……。并进入无限循环。
另一方面,如果我在 app.plist 中放置一个键:NSLocationAlwaysUsageDescription
,并带有一个字符串;不改变代码中的任何内容。然后我的应用程序就可以使用位置功能(LocationAlways)。虽然这比完全没有 GPS 好,但我的应用程序最终会使用 -LocationAlways- 模式,而它很乐意使用 —LocationWhenInUse- 模式。
有人遇到同样的问题并找到解决方案吗?
最佳答案
因为 kCLAuthorizationStatusAuthorized
在 iOS 8 中已弃用
文档
kCLAuthorizationStatusAuthorized This app is authorized to use location services.
Available in iOS 2.0 and later. Deprecated in iOS 8.0
看看枚举的文档,你就会知道为什么kCLAuthorizationStatusAuthorized
有效
typedef enum {
kCLAuthorizationStatusNotDetermined = 0,
kCLAuthorizationStatusRestricted,
kCLAuthorizationStatusDenied,
kCLAuthorizationStatusAuthorized,
kCLAuthorizationStatusAuthorizedAlways = kCLAuthorizationStatusAuthorized,
kCLAuthorizationStatusAuthorizedWhenInUse
} CLAuthorizationStatus;
因此,如果您请求 whenInUse,请使用此 key kCLAuthorizationStatusAuthorizedWhenInUse
关于ios - 位置服务 : LocationAlways vs LocationWhenInUse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33513383/
这是 iOS 应用程序中的一个奇怪行为。这是与我的问题相关的代码: 初始化位置信息: locationManager = [[CLLocationManager alloc] init]; locat
我是一名优秀的程序员,十分优秀!