0

我有一个包含一个实例的类MKMapView

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

虽然我CLLocationManager在项目的其他地方也使用了单例实例,但我发现这个地图视图负责 iPhone 状态栏上显示的“位置”图标。

具体来说,这段代码是罪魁祸首:

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

我试过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...
}

但是,位置状态图标仍然显示...它永远不会关闭,即使经过一个小时后...

如何让在实例上设置showUserLocation为 YES导致的位置状态图标消失?MKMapView

4

1 回答 1

0

事实证明,这是 Apple 框架中某处的错误......

请参阅此问题和选择的答案以获取解决方案:

调用 stopUpdatingLocation 后,位置指示符在状态栏上仍然存在,但仅适用于旧的 Bundle Identifier

本质上,如果您重置位置和隐私(设置 -> 常规 -> 重置 -> 重置位置和隐私),这可以解决问题(只要您还确保showsUserLocation在完成后设置为 NO)。

于 2013-02-26T07:39:21.620 回答