I am tired of finding the problem with this but was unable to get why this happens that the Location Manager's delegate method didEnterRegion
or didExitRegion
is not called ever. I test this in my iPhone but it doesn't work. Please tell me what I am missing. My source code is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; manager = [[CLLocationManager alloc] init]; manager.delegate = self; dist = 100; coord = CLLocationCoordinate2DMake(24.004686, 74.554088); region=[[CLRegion alloc] initCircularRegionWithCenter:coord radius:dist identifier:@"emanuele"]; [manager startMonitoringForRegion:region desiredAccuracy:10]; return YES; } - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{ NSLog(@"Enter Region."); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Got it..." message:@"You have Entered the Location." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; // [alert release]; } - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"didExitRegion"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Got it..." message:@"You have Exited the Location." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; // [alert release]; }
Can anybody figure out what's wrong with??
I have searched many demos and source codes but most of them end with didUpdateToLocation
, which is called in my case, but I have problem with didEnter
and didExit
. I have also implemented the didFailWithError
but it does not do the thing. Please give any clue why these two methods are not called. or give me any link that calls these methods, I found no examples/source for these methods. Any help will be appreciated.