CLLocationManager不会停止 [英] CLLocationManager don't stop
问题描述
亲爱的开发人员,
我正在努力寻找解决CLLocationManager问题的解决方案。
I am trying hard to find a solution for my problem regarfing CLLocationManager.
我在我的应用程序中使用CLLocationManager实例。如果用户选择设备上的主页按钮或终止应用程序,我希望位置服务停止。
I use a CLLocationManager instance in my Application. If the user selects the Home button on the device or terminates the application I want the location services to stop.
因此我调用 [self.locationManager stopUpdatingLocation];
- 但这在某种程度上不起作用。应用程序进入后台,状态栏右上角的小位置箭头不会消失。即使我添加 [self.locationManager release]
或 self.locationManager.delegate = nil;
- 位置跟踪停止: - /
Therefor I call [self.locationManager stopUpdatingLocation];
- But this somehow doesn't work. The application enters the background and the small location arrow in the upper right corner of the status bar don't disappear. Even if I add [self.locationManager release]
or self.locationManager.delegate = nil;
- the location tracking don't stop :-/
如果我转到我的设备设置并关闭应用程序的位置服务,它就会消失。每当我切换回位置服务时,我立即在开关切换旁边看到一个紫色的箭头,图标会重新出现在状态栏中。
It only disappears if I go to my device settings and switch off location services for the app. Whenever I switch back to location service enabled I immediately get a purple colored arrow next to the switch toggle and the icon reappears in the status bar.
我的问题是我怎么能当应用程序进入后台或被终止时关闭位置服务?
My question is how can I turn off location services when the app enters the background or is terminated?
提前多多感谢并祝你有个愉快的一天: - )
Thanks a lot in advance and have a nice day :-)
推荐答案
你这样做是正确的。输入背景时,如果调用某些委托方法几秒钟就可以了。那应该停止。
You do it the right way. When entering background, it's ok if some delegate methods are called for some seconds. That should stop.
你在哪里停止位置更新?你确定它被触发了吗?如果是,即使可视指示器告诉别的东西,你的委托方法是否被调用?
Where do you stop the location updates ? Are you sure it is triggered ? If yes, are your delegate method called even if the visual indicators tell something else ?
你确定你没有触发一个重新激活位置更新的方法吗?停止它(因为例如,即使停止后你也可以收到一些更新)。
Are you sure you don't trigger a method that reactivate the location update after you have stopped it (because for example you can receive some updates even after stopped).
这篇关于CLLocationManager不会停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!