gpt4 book ai didi

ios - 为什么 self.locationManager stopUpdatingLocation 不停止位置更新

转载 作者:IT王子 更新时间:2023-10-29 07:59:13 27 4
gpt4 key购买 nike

问题:我似乎无法阻止 Core Location 向我的应用/跟踪发送更新。

我在做什么:在我的 viewWillAppear 中,我调用了 self.locationManager 并将其传递给一个方法以在 map 上显示用户的位置(MKMapView 的实例)。覆盖 getter 以检查服务的可用性,以查看其是否已授权。如果是这样,它将allocs/initsstartMonitoringSignificantLocationChanges返回

viewDidDisappear 中,我调用了 [self.locationManager stopUpdatingLocation]。但我仍然可以在状态栏中看到位置图标。即使当我通过双击主页按钮并关闭它来终止应用程序时,该图标仍然存在......即使在延长的时间(10 分钟以上)之后。当我转到设置应用程序时,它告诉我我的应用程序仍在使用定位服务(紫色图标)。

问题:我在这里缺少什么?为什么位置更新不会停止?

提前致谢。

最佳答案

startMonitoringSignificantLocationChanges 的反面不是stopUpdatingLocation,而是stopMonitoringSignificantLocationChanges

您可能希望将 startMonitoringSignificantLocationChanges 替换为 startUpdatingLocation 以便进行更定期的更新,除非您有特定原因只监视重要的位置更改。

查看 CLLocation documentation了解更多详情。

关于ios - 为什么 self.locationManager stopUpdatingLocation 不停止位置更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9469741/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com