CoreLocation GPS状态栏指示器不消失
我完全被使用 CoreLocation 的问题难住了。
我在谷歌上检查了一些其他问题,但似乎找不到任何人遇到我遇到的这个特殊问题。
我在我的应用程序中使用 CoreLocation,当我调用 [manager startUpdatingLocation]
时,状态栏上会出现蓝色小箭头,服务开始,一切顺利。
在应用程序中,我有一个 UITabBarController,现在只有第一个选项卡使用 CoreLocation,因此在我的第一个选项卡 ViewController 的 viewDidDisappear
方法中,我调用 [manager stopUpdatingLocation]
现在这里是出了问题,如果我手动点击不同的选项卡,那么当我按照我的预期在选项卡之间来回切换时,蓝色小箭头就会消失并重新出现。
但是,在第一个选项卡上执行某些操作后,它会通过 [self.tabBarController setSelectedIndex:1]
自动切换到另一个选项卡,发生这种情况时,状态栏上的蓝色箭头不会消失,并且即使我不断地在选项卡中来回移动,只要应用程序处于活动状态,该箭头现在基本上就会卡在那里(如果应用程序进入后台,它确实会消失,但会重新出现在任何选项卡上并保持不变)如果它再次激活,就会像以前一样卡在那里)。
现在我想,也许以编程方式更改选项卡不会调用 viewDidDisappear,所以我在那里放置了一个断点,但它确实被调用了。
然后我想...好吧,也许如果我在调用 [self.tabBarController setSelectedIndex:1]
之前调用 [manager stopUpdatingLocation]
可以解决问题,但这并没有也不做任何事。
现在我失去了想法,任何帮助将不胜感激。
PS:我已经测试过 CoreLocation 委托方法是否仍在被调用,并且除非初始选项卡打开,否则它们似乎不再被调用,所以看起来 CoreLocation 似乎已经停止了。然而,从用户的角度来看,情况似乎并非如此。
编辑:似乎这可能是某些第三方库的问题,所以并不是真正可以回答的问题
I'm completely stumped with a problem using CoreLocation.
I've checked out some other questions and on Google but can't seem to find anyone with this particular problem I'm having.
I am utilizing CoreLocation in my App and when I call [manager startUpdatingLocation]
then the little blue arrow on the status bar appears and the service begins and all is well.
In the app I have a UITabBarController, now only the first Tab makes use of CoreLocation so in my first Tab ViewController's viewDidDisappear
method, I call [manager stopUpdatingLocation]
Now here is where things go wrong, If I manually just tap the different tabs then the little blue arrow disappears and re-appears as I go back and forth between the tabs as I would expect them to.
However, upon doing something on the first tab, it will automatically switch to another tab via [self.tabBarController setSelectedIndex:1]
, when this happens, the blue arrow on the status bar does NOT disappear, and even if I continuously go back and forth through the tabs, that arrow is now basically stuck there for as long as the app is active (It does disappear if the app goes into the background though, but will re-appear on any tab and stay stuck there as before if it becomes active again).
Now I thought, maybe changing the tabs programatically doesn't call viewDidDisappear
, so I put a breakpoint there, but it does indeed get called.
Then I thought... Ok maybe if I call [manager stopUpdatingLocation]
just before i call [self.tabBarController setSelectedIndex:1]
that would fix the problem, but that didn't do anything either.
Now I'm lost for ideas and any help would be greatly appreciated.
P.S: I have tested to see if the CoreLocation delegate methods are still being called, and they don't seem to be called anymore unless the initial tab is open, so it does seem as though CoreLocation has stopped. However, from a user perspective this wouldn't seem to be the case.
EDIT: Seems like this might be a problem with some third party libraries, so isn't really something that can be answered
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您释放 CLLocationManager 之前,该指示器不会消失。
编辑:我最初的答案是不正确的,当调用 stopUpdatingLocation 时,该指示器确实应该消失。
编辑2:我创建了一个基本的测试应用程序,在 viewDidDisappear 中调用 stopUpdatingLocation 确实会导致指示器在我的情况下消失。第一个视图控制器的代码如下:
The indicator won't disappear until you release the CLLocationManager.
EDIT: My initial answer was incorrect, the indicator should indeed disappear when stopUpdatingLocation is called.
EDIT 2: I created a basic test application, and calling stopUpdatingLocation in viewDidDisappear does cause the indicator to disappear in my case. Code from the first view controller is below:
所以实际的问题与我无法控制的闭源第三方库有关,所以这个问题没有真正的答案
So the actual problem was related to closed source 3rd party libraries which I had no control of, so this question has no real answer