简体   繁体   English

位置状态栏图标不会消失-MKMapView-iOS 6.1

[英]Location Status Bar Icon Won't Disappear - MKMapView - iOS 6.1

I have a class which contains an instance of MKMapView 我有一个包含MKMapView实例的类

@property(nonatomic, weak) IBOutlet MKMapView *ibMapView;

While I do also use a singleton instance of CLLocationManager in other places in the project, I've found that this map view is responsible for the "Location" icon showing on the iPhone status bar. 虽然我还在项目的其他位置使用了CLLocationManager的单例实例,但我发现此地图视图负责显示在iPhone状态栏上的“位置”图标。

Specifically, this code is to blame: 具体来说,该代码应归咎于:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // If I comment out this line below, the "Location" status icon never shows, as expected 
    self.ibMapView.showsUserLocation = YES;

    // ...other magical stuff happens here, not related to map view
}

I've tried setting showsUserLocation to NO like this 我已经尝试将showsUserLocation设置为NO,就像这样

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.ibMapView.showsUserLocation = NO;

    // I also have tried logging to make sure showUserLocation is set to NO- returns "NO" as expected
    DebugLog(@"Show User Location: %@", self.ibMapView.showsUserLocation ? @"YES" : @"NO");

    // ...other stuff happens here, not related to map view...
}

However, the location status icon still shows... it never turns off, even after an hour has passed... 但是,位置状态图标仍显示...即使经过一个小时,它也永远不会关闭...

How can I get the location status icon caused by setting showUserLocation to YES on an MKMapView instance to go away? 如何将MKMapView实例上的showUserLocation设置为YES导致的位置状态图标消失?

As it turns out, this is a bug in Apple's frameworks somewhere... 事实证明,这是苹果框架中的一个错误……

See this question and the selected answer for a solution: 查看此问题和选择的答案以获取解决方案:

Location indicator persists on status bar after stopUpdatingLocation is called, but only for old Bundle Identifier 在调用stopUpdatingLocation之后,位置指示器在状态栏上仍然存在,但仅适用于旧的捆绑包标识符

Essentially, if you Reset Location & Privacy (Settings -> General -> Reset -> Reset Location & Privacy), this fixes the issue (as long as you also make sure that you set showsUserLocation to NO once you're done it with). 本质上,如果您重置位置和隐私 (设置->常规->重置->重置位置和隐私),则可以解决此问题(只要您还确保在完成操作showsUserLocation设置为NO,即可) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM