位置管理器上的计时器 [英] Timer on Location Manager

查看:127
本文介绍了位置管理器上的计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Timer 内调用 didUpdateLocations ?我的意思是..

Is it possible to invoke didUpdateLocationsinside the Timer ? I mean..

_timer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(_:didUpdateLocations:)), userInfo: nil, repeats: true) 

这行得通吗?如果是,那么它将每10秒更新一次位置吗?

Is that going to work ? If yes then it is going to update location every 10 seconds ?

推荐答案

您无法调用didUpdateLocations。如果您希望经常更新,最好的选择是标准位置服务:

You can't invoke didUpdateLocations. If you want frequent updates, your best choice is the Standard location service:


标准位置服务最适合$ b $的应用b直接将位置相关信息传递给用户,但
也可能被其他类型的应用程序使用。要启动该服务,请将
配置为位置
管理器的requiredAccuracy和distanceFilter属性,然后调用requestLocation(),startUpdatingLocation(),
或allowDeferredLocationUpdates(untilTraveled:timeout :)方法。
绝对不要指定比您需要的精度更高的精度值。核心位置
使用您指定的精度值更好地管理电源。较高的
精度需要更精密的硬件,例如GPS,
会消耗更多功率。

The standard location service is most appropriate for apps that deliver location-related information directly to the user but it may be used by other types of apps too. To start the service, configure the desiredAccuracy and distanceFilter properties of the location manager and then call the requestLocation(), startUpdatingLocation(), or allowDeferredLocationUpdates(untilTraveled:timeout:) method. Never specify an accuracy value greater than what you need. Core Location uses the accuracy value you specify to manage power better. A higher degree of accuracy requires more precise hardware like GPS, which consumes more power.

https://developer.apple.com/reference/corelocation/cllocationmanager

这篇关于位置管理器上的计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆