为什么self.locationManager stopUpdatingLocation不会停止位置更新 [英] why self.locationManager stopUpdatingLocation doesn't stop location update

查看:1104
本文介绍了为什么self.locationManager stopUpdatingLocation不会停止位置更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我似乎无法阻止核心位置将更新发送到我的应用/跟踪。

Problem: It seems I can't stop Core Location from sending updates to my app / tracking.

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

What am I doing: In my viewWillAppear I call self.locationManager and pass it to a method to show user's location on the map (an instance of MKMapView). The getter is overridden to check for availability of the serive, to see whether its authorized. If so, it allocs/inits and startMonitoringSignificantLocationChanges and returns.

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

In viewDidDisappear, I call [self.locationManager stopUpdatingLocation]. But still I can see the location icon in the status bar. Even when I terminate the app by double tapping the home button and closing it, the icon is still there... even after extended amount of time (10+ minutes). When I go to the Settings App, it tells me that my app is still using location services (purple icon).

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

Question: What am I missing here? Why location update doesn't stop?

提前致谢。

推荐答案

startMonitoringSignificantLocationChanges 的反面不是 stopUpdatingLocation ,它是 stopMonitoringSignificantLocationChanges

你可能想用 startUpdatingLocation startMonitoringSignificantLocationChanges c>为了更频繁的更新,除非您有特定的理由仅监控重要的位置更改。

You probably want to replace startMonitoringSignificantLocationChanges with startUpdatingLocation for the sake of more regular updates, unless you have a specific reason for monitoring only for significant location changes.

查看 CLLocation文档了解更多详情。

这篇关于为什么self.locationManager stopUpdatingLocation不会停止位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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