如果不调用 startUpdatingLocation,我可以从 LocationManager 获取当前位置吗?

Can I get current location from LocationManager if not calling startUpdatingLocation?

正如主题所说,我想在不调用 startUpdatingLocation 的情况下出现视图时通过以下代码获取当前位置。这可能吗?

curLocation = locationManager.location

我的 运行 应用程序将在启动时调用 startUpdatingLocation 运行,所以我不想在视图出现方法时调用它。

非常感谢!

我不确定您究竟在寻找什么,但您可以使用 requestLocation() 一次性获取当前位置。它将使用结果调用 locationmgr(didUpdateLocations)。