![](/img/trans.png)
[英]CLLocationmanager updateLocations delegate method not getting called in iOS 8
[英]iOS 8 CLLocationManager enterRegion: not getting called if use requestWhenInUseAuthorization
我正在嘗試在 iOS 8 中為自定義區域調用委托方法 locationManager:didEnterRegion。 這是代碼:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(20, 20) radius:1000 identifier:@"asda"];
region.notifyOnEntry = YES;
region.notifyOnExit = YES;
[self.locationManager startMonitoringForRegion:region];
它確實調用了locationManager:didStartMonitoringForRegion
方法,但它不調用“進入”或“退出”區域方法。
更奇怪的是,如果我對 locationManager 使用 requestAlwaysAuthorization,它確實可以工作。 但我需要讓它與“使用時”一起工作。
注意:在 iOS7 中,它適用於 WhenInUse 和 Always Authorization 方法。
區域監控 - 它不適用於requestWhenInUseAuthorization
檢查 Apple Docs:“ .. “when-in-use” ... Apps cannot use any services that automatically relaunch the app, such as region monitoring or the significant location change service
“
您必須調用requestAlwaysAuthorization
!!! https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestWhenInUseAuthorization
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.