startUpdatingMyLocation是否强制调用iphone sdk中位置管理器的didUpdateToLocation方法
我需要澄清一下。 startUpdatingMyLocation 方法必须调用 didUpdateToLocation 吗?更新位置时不是会自动调用 didUpdateToLocation 方法吗?
请伙计澄清我的澄清。
I need a clarification that. Is startUpdatingMyLocation method mandatory to call didUpdateToLocation? isn't the didUpdateToLocation method automatically called when the location is updated?
Guy's please clear my clarification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件指出
因此,您可以使用两者中的任何一个(
startUpdatingLocation
或startMonitoringSignificantLocationChanges
)来获取位置更新,但您必须为正在调用的委托方法调用其中任何一个。 (恕我直言)The documents state
So you can use any of the two , either
startUpdatingLocation
orstartMonitoringSignificantLocationChanges
to get the location updates but you will have to call any one of these for the delegate method being called. (IMHO)通过调用 startUpdatingLocation 方法启动标准位置服务。此服务最适合需要对位置事件的传递进行更细粒度控制的应用程序。具体来说,它会考虑desiredAccuracy 和distanceFilter 属性中的值来确定何时传递新事件。导航应用程序或任何需要高精度位置数据或定期更新流的应用程序都需要标准位置服务的精度。然而,这些服务通常需要启用位置跟踪硬件较长时间,这可能会导致更高的功耗。
对于不需要常规位置事件流的应用程序,请考虑使用 startMonitoringSignificantLocationChanges 方法来启动事件传递。此方法更适合大多数只需要初始用户位置修复并且仅当用户移动很远距离时才需要更新的应用程序。仅当该接口检测到设备关联的蜂窝塔发生更改时,它才会传送新事件,从而减少更新频率并显着降低功耗。
无论您使用哪种位置服务,位置数据都会通过位置管理器的关联委托对象报告给您的应用程序。由于返回初始位置可能需要几秒钟的时间,因此位置管理器通常会立即传送先前缓存的位置数据,然后在可用时传送更多的最新位置数据。因此,在采取任何操作之前检查任何位置对象的时间戳始终是一个好主意。如果同时启用两个位置服务,它们将使用同一组委托方法传递事件。
Start standard location services by calling the startUpdatingLocation method. This service is most appropriate for applications that need more fine-grained control over the delivery of location events. Specifically, it takes into account the values in the desiredAccuracy and distanceFilter property to determine when to deliver new events. The precision of the standard location services are needed by navigation applications or any application where high-precision location data or a regular stream of updates is required. However, these services typically require the location-tracking hardware to be enabled for longer periods of time, which can result in higher power usage.
For applications that do not need a regular stream of location events, consider using the startMonitoringSignificantLocationChanges method to start the delivery of events instead. This method is more appropriate for the majority of applications that just need an initial user location fix and need updates only when the user moves a significant distance. This interface delivers new events only when it detects changes to the device’s associated cell towers, resulting in less frequent updates and significantly lower power usage.
Regardless of which location service you use, location data is reported to your application via the location manager’s associated delegate object. Because it can take several seconds to return an initial location, the location manager typically delivers the previously cached location data immediately and then delivers more up-to-date location data as it becomes available. Therefore it is always a good idea to check the timestamp of any location object before taking any actions. If both location services are enabled simultaneously, they deliver events using the same set of delegate methods.