没有调用LocationManager didEnterRegion

时间:2018-06-14 05:46:48

标签: ios objective-c iphone core-location

我创建了一个CLCircularRegion并开始监控该区域。但是当我到达该位置时,或者当我从调试中设置位置时,我没有获得委托locationManager:didEnterRegion。

注意:我已在info.plist中添加了Authorization Always,已启用位置管理器已选中。头文件具有CLLocationManagerDelegate。

self.locationManager_ = [ [ CLLocationManager alloc ] init ];
self.locationManager_.delegate = self;
self.locationManager_.distanceFilter = 10;
self.locationManager_.desiredAccuracy = kCLLocationAccuracyBest;

if([self.locationManager_ respondsToSelector:@selector(requestAlwaysAuthorization)])
{
    [ self.locationManager_ requestAlwaysAuthorization ];
}

在这里,我允许将位置授权设置为Always,并在点击按钮时调用以下方法。

CLCircularRegion* circularRegion = [ [ CLCircularRegion alloc ] initWithCenter:center radius:radius identifier:identifier ];    
[locationManager_ startMonitoringForRegion:circularRegion];

并实现了委托方法。 AppDelegate.h

@interface AppDelegate : UIResponder <UIApplicationDelegate,CLLocationManagerDelegate>
@end

AppDelegate.m

下面的委托方法不叫

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    NSLog(@"Did enter region");
}

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
    NSLog( @"monitoringDidFailForRegion %@", region );
    NSLog( @"monitoringDidFailForRegion Error %@", error );
}

0 个答案:

没有答案