I am using CLLocationManager to monitor regions in iOS. I set up the delegate in the normal way:
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
and implement several delegate functions including:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"GeoFence: didEnterRegion");
}
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"GeoFence: didExitRegion");
}
Then I start monitoring a region with:
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(lat, lng);
CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:radius identifier:[NSString stringWithFormat:@"grRegion%i", 1]];
CLLocationAccuracy acc = kCLLocationAccuracyNearestTenMeters;
[self.locationManager startMonitoringForRegion:grRegion desiredAccuracy:acc];
with appropriate values for lat (51.116261), lng (-0.85300) and radius (200). After building and running the app in the iPhone 5.1 simulator, I use the location injection tool in Xcode 4.3 to move between a distant location to my target location and back again. Under this procedure, the didEnterRegion event correctly triggers but the didExitRegion never does. I also receive other delegate callbacks such as didUpdateToLocation. I have varied the pattern of simulated movements, used the simulator's location setting tool rather than Xcode's, and tried the same tests running the app on an iPhone 4S with iOS 5.1. All tests have the same result.
I have ensured WiFi is enabled as suggested in other threads and looked through other questions on related topics in vain. Any suggestions as why one of the region transition events would fire, but not the other?