草庐IT

ios - CLLocationManager 的 startMonitoringSignificantLocationChanges() 和 startUpdatingLocation() 方法有什么区别?

coder 2023-09-05 原文

我正在使用 CLLocationManager 类。我想定期获取位置更新。我在 didUpdateLocations 方法中找到了两种获取位置的方法,即 startUpdatingLocation()startMonitoringSignificantLocationChanges()。如果我还必须在前台模式下跟踪位置更新,那么我应该使用哪种方法?

最佳答案

两者之间最重要的区别是:

startMonitoringSignificantLocationChanges: it does not rely on the value in the distanceFilter property to generate events. The receiver generates update events only when a significant change in the user’s location is detected

startUpdatingLocation : the receiver generates update events primarily when the value in the distanceFilter property is exceeded

因此,如果您想要更精确,请选择 startUpdatingLocation,但代价是电池消耗更多,但位置更精确。这实际上取决于您的目标,您应该权衡取舍。

关于ios - CLLocationManager 的 startMonitoringSignificantLocationChanges() 和 startUpdatingLocation() 方法有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35285693/

有关ios - CLLocationManager 的 startMonitoringSignificantLocationChanges() 和 startUpdatingLocation() 方法有什么区别?的更多相关文章

随机推荐