모니터링 지역을 사용하여 사용자가 랜드 마크를 방문했는지 추적하려고합니다. 위치 관리자는 뷰 컨트롤러의 viewDidLoad에서 mapkitiphone CLLocationmanager 지역 모니터링 콜백이 트리거되지 않았습니다.
와 함께의 ViewController 초기화된다
if (self.locationManager == nil)
{
// NSLog(@"creating location manager");
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = kCLDistanceFilterNone;
}
NSSet* set=[locationManager monitoredRegions];
if ([CLLocationManager regionMonitoringAvailable] && [CLLocationManager regionMonitoringEnabled]) {
NSLog(@"region monitoring okay");
NSLog(@"monitored regions: %@",set);
}
제가 정확하게 모든 영역 "괜찮 모니터링 영역의"NSLogs을 얻는다. 지역의 추가
그렇게
double metres=20.0;
CLLocationDistance dist=metres;
CLLocationAccuracy acc=1.0;
CLRegion *reg=[[CLRegion alloc] initCircularRegionWithCenter:coordinate radius:dist identifier:landmarkObj.landmarkName];
[locationManager startMonitoringForRegion:reg desiredAccuracy:acc];
처럼 수행되지만 콜백 모든 그러나 위치를 업데이트
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Entered"
message:region.identifier
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Exited"
message:region.identifier
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
NSLog(@"started monitring for region: %@",region);
}
- (void) locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
NSLog(@"%@",error);
}
을 유발하지 않는, 잘 작동합니다. 대신 지역에 대한 모니터링하는 데 사용 didUpdatToLocation :
[locationManager startUpdatingLocation];
예상
업데이트로 콜백 didUpdateToLocation을 트리거합니다. 여전히 이것이 작동하지 않는 이유를 알고 싶습니다. 지역 모니터링에 성공한 사람이 거의없는 것처럼 보입니다.
이 문제에 대한 해결책을 찾아 냈습니까? 같은 문제가 있고 didStartMonitoringForRegion이 실행되지 않습니다. – Das
지역 모니터링만으로는 내가 필요한 정밀도를주지 못하는 것으로 나타났습니다. 나는 모든 didUpdateToLocation 콜백에 대한 수동 검사를 끝내었다. 이것은 내가 10 지역만을 추적했기 때문에 가능했다. – tzl