Objective c 是否未调用地理围栏didEnterRegion和didExitRegion方法?
嗨,伙计们,我在做地理围栏!Location manager DidDetermingEstate正在正确调用,但当我输入region时,从未调用过didEnterRegion和didExitRegion 这是我的密码Objective c 是否未调用地理围栏didEnterRegion和didExitRegion方法?,objective-c,ios7,xcode5,geofencing,Objective C,Ios7,Xcode5,Geofencing,嗨,伙计们,我在做地理围栏!Location manager DidDetermingEstate正在正确调用,但当我输入region时,从未调用过didEnterRegion和didExitRegion 这是我的密码 **ViewController.m** GeofenceMonitor * gfm = [GeofenceMonitor sharedObj]; NSMutableDictionary * fence1 = [NSMutableDictionary new]; [fe
**ViewController.m**
GeofenceMonitor * gfm = [GeofenceMonitor sharedObj];
NSMutableDictionary * fence1 = [NSMutableDictionary new];
[fence1 setValue:@"office" forKey:@"identifier"];
[fence1 setValue:@"13.04765701" forKey:@"latitude"];
[fence1 setValue:@"80.18752289" forKey:@"longitude"];
[fence1 setValue:@"100" forKey:@"radius"];
[fence1 setValue:@"11" forKey:@"id"];
NSMutableDictionary * fence2 = [NSMutableDictionary new];
[fence2 setValue:@"axis baank end" forKey:@"identifier"];
[fence2 setValue:@"13.04705048" forKey:@"latitude"];
[fence2 setValue:@"80.18778229" forKey:@"longitude"];
[fence2 setValue:@"100" forKey:@"radius"];
[fence2 setValue:@"12" forKey:@"id"];
if([gfm checkLocationManager])
{
[gfm addGeofence:fence1];
[gfm addGeofence:fence2];
[gfm findCurrentFence];
}
GeofenceMonitor.m
请尝试调用主线程
if ([CLLocationManager locationServicesEnabled])
{
[self performSelectorOnMainThread:@selector(updateLocation) withObject:self waitUntilDone:NO];
}
- (void)updateLocation
{
arr_region=[[NSMutableArray alloc] init];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
[locationManager startUpdatingLocation];
}
我希望它能有所帮助。+20我一直在寻找同样的东西。
if ([CLLocationManager locationServicesEnabled])
{
[self performSelectorOnMainThread:@selector(updateLocation) withObject:self waitUntilDone:NO];
}
- (void)updateLocation
{
arr_region=[[NSMutableArray alloc] init];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
[locationManager startUpdatingLocation];
}