【发布时间】:2014-09-12 13:01:33
【问题描述】:
我正在尝试在 iOS 8 中使用重大更改位置监控,但从未调用过 didUpdateLocations 方法。这是设置位置管理器的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager requestWhenInUseAuthorization];
[locationManager startMonitoringSignificantLocationChanges];
}
尽管调用requestWhenInUseAuthorization,但没有弹出请求用户授权。我已经设置了 NSLocationWhenInUseUsageDescription,但它仍然不起作用。 didChangeAuthorizationStatus 和 didFailWithError 也永远不会被调用。
编辑:我能够让它要求用户允许位置服务,但即使你点击允许它也不会显示位置。
【问题讨论】:
-
这主要是因为人们没有将 NSLocationAlwaysUsageDescription 或 NSLocationWhenInUseUsageDescription 添加到 info.plist 文件中,但您说您已经拥有它,那么 CLLocationManagerDelegate 呢。 iOS 8 gps not enabled
-
我将委托设置为 self,并且我在标题中有
。 -
@charleyh:我面临同样的问题。你有什么解决办法吗?
-
我在这里发布了关于 iOS 8 中位置管理器的一些更改:nevan.net/2014/09/core-location-manager-changes-in-ios-8
-
在这种特殊情况下(至少在编辑之前),原因可能是位置管理器在内存中保存的时间不够长。请参阅下面的答案。
标签: ios cocoa-touch core-location ios8