jjzjj

iphone - CLLocationManager didEnterRegion 错误通知

coder 2024-01-27 原文

我在玩 CLLocaitonManager 时遇到了非常奇怪的情况......

manager = [[CLLocationManager alloc] init];
[manager setDistanceFilter:kCLDistanceFilterNone];
[manager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
manager.delegate = self;

我正在对半径为 10.0 米的区域使用区域跟踪...

[manager startMonitoringForRegion:region];

我定义的区域彼此非常接近,但绝对不会接近 50-100 米...当我在 iOS (5.0) 模拟器中测试我的应用程序时(通过将位置设置为 Apple,然后返回到我的自定义位置) 我同时收到多个通知,对于彼此靠近的区域...我还在检查检测到的区域位置与我当前位置之间的距离...

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
CLLocation *regionLocation = [[CLLocation alloc] initWithLatitude:region.center.latitude longitude:region.center.longitude];

NSLog(@"didEnterRegion: %@ %f", region.identifier, [regionLocation distanceFromLocation:mapView.userLocation.location]);

[self notifyUserDidEnterRegion:region];
}

问题是我收到了距离我当前位置 200 米的区域的通知...而且几乎同时我收到的通知很少...

有什么建议吗?还是我应该提供更多详细信息?

最佳答案

区域监控仅限于此。不幸的是,您无法获得米范围内的精度,它们在 iOS5 中改进了大约 200 米的范围,但这取决于很多因素,因为它基于蜂窝塔三角测量和 wifi 点。我发现获得更高精度的唯一方法是在您接近目标时更改精度并在您离开时再次注册。为此您应该为 GPS 激活多任务处理,但如果您实现得好算法它不会消耗所以很多电池。 希望这可以帮助, 安德里亚

关于iphone - CLLocationManager didEnterRegion 错误通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9165577/

有关iphone - CLLocationManager didEnterRegion 错误通知的更多相关文章

随机推荐