有谁知道使用这个的任何知识:
- (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 的:
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);
}
谢谢