gpt4 book ai didi

ios 8 Locationmanager不请求许可

转载 作者:行者123 更新时间:2023-11-29 02:24:07 26 4
gpt4 key购买 nike

我无法让 LocationManager 与 IOS8 一起使用,我已将两个新值添加到 plist 中并执行请求。但它仍然不起作用。我做错了什么?

Plist:enter image description here

这是我的代码:

locationManager = [[CLLocationManager alloc] init];


locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;

[locationManager requestAlwaysAuthorization];

[locationManager startUpdatingLocation];

float latitude = locationManager.location.coordinate.latitude;
float longitude = locationManager.location.coordinate.longitude;

我没有收到任何许可请求。

最佳答案

首先尝试从模拟器/设备中删除您的应用。

然后将您的授权行更改为:

if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[[[LocationManager sharedInstance] locationManager] requestAlwaysAuthorization];
}

将 NSLocationAlwaysUsageDescription 添加到您的 plist(尝试使用/不使用 WhenInUseUsageDescription 作为第二个)。

关于ios 8 Locationmanager不请求许可,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27756100/

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