简体   繁体   中英

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

I have a class which contains an instance of 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.

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

- (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?

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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