この件に関して 4 番目の質問を投稿することを本当に躊躇しましたが、以前の回答に従ってすべてをトリプルチェックしましたが、それでも悪い結果が得られました。
問題: CLLocationManager がiOS6 でdidEnterRegionを呼び出さない。
セットアップ: iOS6.
CLLocationManagerに関連するすべての関数を含むコードは次のとおりです
myMapViewController.h
@interface FirstViewController : UIViewController <UIApplicationDelegate,CLLocationManagerDelegate, MKMapViewDelegate, UISearchBarDelegate,RKObjectLoaderDelegate >
{
/* variables */
}
@property (strong, nonatomic) CLLocationManager *locationManager;
myMapViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
/* other initialization code */
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter: kCLLocationAccuracyBest];
[locationManager setDesiredAccuracy: kCLLocationAccuracyBest];
}
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
/* other application code */
Step* step = [_steps lastObject];
CLRegion *tmpReg = [[CLRegion alloc] initCircularRegionWithCenter:step.start_location.coordinate radius:1000 identifier: [step.start_locationLat stringValue] ];
[locationManager startMonitoringForRegion:tmpReg];
NSLog(@"Setting region with latitude %f", tmpReg.center.latitude);
}
- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region{
NSLog(@"Monitoring region with latitude %f", region.center.latitude);
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
NSLog(@"ENTERED REGION!");
}
}
- (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region{
NSLog(@"EXITED REGION!");
}
- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
NSLog(@"Region monitoring failed with error: %@", [error localizedDescription]);
}
アプリケーションは警告なしで実行され、ログは次のとおりです。
2012-12-02 19:31:41.449 myApp[5695:c07] Setting region with latitude 37.785690
2012-12-02 19:31:41.506 myApp[5695:c07] Monitoring region with latitude 37.785690