【发布时间】:2011-04-12 03:50:24
【问题描述】:
这两种方法中哪一种在确定用户位置时更准确?
// First
[locationManager startUpdatingLocation]
// Second
[locationManager startMonitoringSignificantLocationChanges]
【问题讨论】:
标签: objective-c ios4 core-location
这两种方法中哪一种在确定用户位置时更准确?
// First
[locationManager startUpdatingLocation]
// Second
[locationManager startMonitoringSignificantLocationChanges]
【问题讨论】:
标签: objective-c ios4 core-location
根据Apple CoreLocation documentation,startUpdatingLocation更准确。来自文档:
您可以通过调用 startUpdatingLocation 方法来启动标准位置服务。此服务最适合需要对位置事件的传递进行更细粒度控制的应用程序。具体来说,它会考虑 desiredAccuracy 和 distanceFilter 属性中的值来确定何时传递新事件。这最适合导航应用程序或任何需要高精度位置数据或定期更新流的应用程序。
将此与startMonitoringSignificantLocationChanges 进行对比,根据文档,后者更粗略且不太准确:
对于不需要常规位置事件流的应用程序,您应该考虑使用 startMonitoringSignificantLocationChanges 方法来开始传递事件。这种方法更适合大多数只需要初始用户位置修复并且仅在用户移动很长距离时才需要更新的应用程序。此界面仅在检测到设备关联的信号塔发生变化时才会提供新事件,从而降低更新频率并显着提高电源使用率。
您可以使用CLLocationManager 类的desiredAccuracy 属性控制位置更新的准确性。
【讨论】:
第一个会在CLLocationManager 类的desiredAccuracy 集合中为您提供更新。另请注意,distanceFilter 也很重要。
仅当您移动“显着”距离时才会触发显着的位置更改,这意味着更新很少。
【讨论】: