私は位置情報ベースのアプリを持っています。地域は正しいのですが、アプリが移動し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 に新しい場所を入力しました