我尝试在 iOS 8 中使用显着变化位置监控,但从未调用 didUpdateLocations 方法。以下是设置位置管理器的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager requestWhenInUseAuthorization];
[locationManager startMonitoringSignificantLocationChanges];
}
尽管调用了 requestWhenInUseAuthorization
,但没有弹出任何内容要求用户授权。我已经设置了 NSLocationWhenInUseUsageDescription,但它仍然不起作用。 didChangeAuthorizationStatus
和 didFailWithError
也从未被调用。
编辑:我能够让它要求用户允许定位服务,但即使你点击允许它也永远不会显示位置。
最佳答案
目前 iOS8 beta5 中存在一个错误,它总是停用您的应用程序的地理定位服务(至少对我的应用程序而言)。
进入 设置 > 隐私 > 定位服务 > 你的应用程序 > 始终
。
但我不知道为什么,但即使您将其设置为Always
,此设置也会自动停用,因此请耐心等待并经常返回设置以重新配置您的应用程序位置。
关于ios - 核心位置在 iOS 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24874997/