我有一个基于位置的应用程序,尽管该区域是正确的,但该应用程序永远不会移动到didEnterRegion
或didExitRegion
for (int x = 0; x <= [[[TaskStore sharedStore] allTasks]count]-1; x++)
{
NSArray *tasks = [[TaskStore sharedStore] allTasks];
Task *selectedTask = [tasks objectAtIndex:x];
location.latitude = selectedTask.locationCoord.coordinate.latitude;
location.longitude = selectedTask.locationCoord.coordinate.longitude;
NSString* desiriedLoc = [selectedTask locationName];
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter: location radius: 30.0 identifier: desiriedLoc];
NSLog(@"Entered new Location in Region %@", region);
[locManager startMonitoringForRegion:region];
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"didEnterRegion for %@",region.identifier);
UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didEnterRegion"
message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
[alr show];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"didExitRegion for %@",region.identifier);
UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didExitRegion" message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
[alr show];
}
这是从我的位置打印出来的字符串:
输入坐标纬度的新位置:51.509980 经度:-0.133700
这是从该区域打印出来的字符串:
在区域中输入新位置(标识符伦敦)<+51.50998000,-0.13370000> 半径 30.00m