2

我正在尝试在 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];

它确实调用了 method locationManager:didStartMonitoringForRegion,但不调用“进入”或“退出”区域方法。

一件更奇怪的事情是,如果我对 locationManager 使用 requestAlwaysAuthorization,它确实有效。但我需要让它与“使用时”一起使用。

注意:在 iOS7 中,它适用于 WhenInUse 和 Always Authorization 方法。

4

1 回答 1

1

区域监控 - 它不适用于requestWhenInUseAuthorization

检查苹果文档:“ .. “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

于 2015-06-09T10:04:55.223 回答