Кто-нибудь знает какие-либо знания по использованию этого:
- (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
Я пытаюсь внедрить его в свой проект, но:
- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
никогда не вызывается?
Кто-нибудь имеет пример кода или знает, почему это происходит?
Мой код выглядит следующим образом. Я создал такой метод в своем собственном классе LocationManager:
- (void) locationManagerStartMonitoringRegion:(CLRegion *)region withAccuracy:(CLLocationAccuracy)accuracy {
NSLog(@"Start Monitoring");
[locationManager startMonitoringForRegion:region desiredAccuracy:accuracy];
NSLog(@"Monitored Regions: %i", [[locationManager monitoredRegions] count]);
}
Я тогда называю это так:
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(51.116261, -0.853758);
CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:150 identifier:[NSString stringWithFormat:@"grRegion%i", value]];
[locationManager locationManagerStartMonitoringRegion:grRegion withAccuracy:kCLLocationAccuracyBest];
Я получаю NSLog's:
2011-01-30 19: 52: 26.409 Место тестирования [10858: 307] Запуск мониторинга
2011-01-30 19: 52: 27.103 Место тестирования [10858: 307] Отслеживаемые регионы:
Но никогда не получайте NSLog от:
- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Entered Region");
}
или
- (void) locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error {
NSLog(@"monitoringDidFailForRegion: %@",error);
}
Спасибо