我已经通过调用开始了区域监控startMonitoringForRegion
。但是我发现didStartMonitoringForRegion
被调用了两次也didEnterRegion
被调用了两次。但我startMonitoringForRegion
只打电话一次。我的代码
- (void) enableRegionMonitoring:(NSMutableDictionary *)locationInfoDic{
NSLog(@"started Loc Mon");
locMgr = [[CLLocationManager alloc] init];
[locMgr setDelegate:self];
NSString *locationId=[[NSString alloc]init];
double latitude=[[locationInfoDic objectForKey:@"lat"] doubleValue];
double longitude=[[locationInfoDic objectForKey:@"lon"] doubleValue];
if([locationInfoDic objectForKey:@"key"]){
locationId=[locationInfoDic objectForKey:@"key"] ;
}else{
locationId=@"NA";
}
CLLocationCoordinate2D myMonLocation = CLLocationCoordinate2DMake(latitude, longitude);
CLRegion *myRegion = [[CLRegion alloc]
initCircularRegionWithCenter:myMonLocation
radius:100
identifier:locationId];
[locMgr startMonitoringForRegion:myRegion
desiredAccuracy:kCLLocationAccuracyBest];
}
- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region{
NSLog(@"Region monitoring started\n%@",[region description]);
}