didUpdateLocations 需要很长时间才能加载

didUpdateLocations is taking a long time to load

您好,我目前正在开发一个使用 Mapkit 的 IOS 应用程序。我的应用程序当前正在使用 locationmanager 获取用户位置并设置区域。现在发生的一件奇怪的事情是,当我在不同的位置时,为 setregion 设置动画所需的时间是不同的。

例如,当我在学校时,手机信号很弱。当我在蜂窝信号很强的家里时,mapkit 设置区域所需的时间大约要长 10 倍。

我目前正在使用 requestLocation() 调用 didupdatelocation 函数,网上的人建议使用 startUpdatingLocation。关于这个的事情是我只想在我的应用程序中设置一次区域。而 didupdatelocation 则一直在做。

我有点卡住了,不知道从哪里开始解决这个问题。请帮忙!

For example when I'm at the school where cellular signals is weak. The time it takes for mapkit to set region is about 10x longer when i'm at home where the cellular signal is strong.

  • 这是预期的行为。检索位置是一项网络密集型任务,但是请配置 desiredAccuracy and distanceFilter properties of the location manager and then call the requestLocation or startUpdatingLocation.
  • 切勿指定大于您需要的精度值。 Core Location 使用您指定的精度值更好地管理电源。
    更高的准确度需要更精确的硬件,例如 GPS,这会消耗更多电量。

The thing about this is that i only want to setregion once in my app.

  • nil 消息传递给 CLLocationManager 实例将阻止任何连续的 didUpdateLocation: 调用。