【问题标题】:Location Service indicator on status bar still appears even after explicitly called stopUpdatingLocation on CLLocationManager即使在 CLLocationManager 上显式调用 stopUpdatingLocation 后,状态栏上的位置服务指示器仍然出现
【发布时间】:2013-09-02 04:19:35
【问题描述】:

我有一个视图,它有一个地图视图的子视图。我使用 CLLocationManager 来获取当前位置并显示在地图上。然后当视图即将关闭时,我执行以下操作

_mapView.delegate = nil;
_mapView = nil;

[_locationManager stopUpdatingLocation];
_locationManager.delegate = nil;
_locationManager = nil;

但状态栏上的定位服务(GPS)指示灯仍然保持不变。当应用程序进入后台然后返回前台时,它会等待指示器显示在状态栏上,然后再激活。

指标还存在有什么原因吗?

编辑 - 以下是 CLLocationManager 的初始化和启动方式

    if (_locationManager == nil) {
        _locationManager = [[CLLocationManager alloc] init];
        _locationManager.delegate = self;
        _locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
        _locationManager.distanceFilter = kCLDistanceFilterNone;

        [_locationManager startUpdatingLocation];
    }  

以下是我停止它的方法

    if (_locationManager != nil) {
        [_locationManager stopUpdatingLocation];
        _locationManager.delegate = nil;
        _locationManager = nil;
    }

【问题讨论】:

    标签: ios mkmapview cllocationmanager statusbar


    【解决方案1】:

    正如定位工程师在 WWDC 上所解释的那样,该图标会在右上角保留特定的时间,具体取决于上次使用的服务。我相信一旦你停止使用位置,[locationManager stopUpdatingLocation],计时器会在图标消失之前开始。某些服务的时间更长。他们没有详细说明这些计时器有多长。我知道它们会在 iOS 6 中变得更长。

    一旦您停止监控位置,只需等待(30-60 秒),然后查看图标是否消失。它应该假设你已经停止了一切。希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题,在这里找到了答案:

      What determines the presence of the iPhone Location Services icon in the status bar?

      我的解决方案(正在开发中)是重置位置警告(设置 > 常规 > 重置 > 重置位置警告)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多