【问题标题】:CLLocationManagerDelegate -locationManager(_:startMonitoring:) not called when there is no network没有网络时不调用 CLLocationManagerDelegate -locationManager(_:startMonitoring:)
【发布时间】:2018-12-04 08:32:24
【问题描述】:

当我在 iPhone 上打开飞行模式时,

func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion)

不再被调用。但是,当我关闭飞行模式时,会调用此委托。

在 CLLocationManager 中这是正常的吗?或者我的属性设置错误。

我已经设置了所有属性。

lazy var locationManager: CLLocationManager = {
    let lm = CLLocationManager()
    lm.allowsBackgroundLocationUpdates = true
    lm.pausesLocationUpdatesAutomatically = false
    lm.showsBackgroundLocationIndicator = true
    lm.delegate = self
    lm.requestAlwaysAuthorization()
    let authorizationStatus = CLLocationManager.authorizationStatus()
    for region in lm.monitoredRegions {
        lm.stopMonitoring(for: region)
    }
    return lm
}()

locationManager.startMonitoring(for: region)

【问题讨论】:

    标签: ios iphone swift core-location cllocationmanager


    【解决方案1】:

    飞行模式也会关闭 GPS,所以是的,不会接收位置更新,因此预计不会调用 CLLocationManagerDelegate 方法。

    【讨论】:

    • 如果重启设备,locationManager的区域会正常工作吗?
    • @DeanLee 退出飞行模式应该可以解决问题,无需重启设备
    • 谢谢,但我的意思是用户注册一个区域然后关闭设备并关闭它,该区域可以正常工作吗?这两个问题之间没有关系。
    • @DeanLee 那么你应该问一个新问题,如果它与这个问题完全无关并因此回答:)
    猜你喜欢
    • 1970-01-01
    • 2015-01-08
    • 2014-12-13
    • 2016-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-12
    • 1970-01-01
    相关资源
    最近更新 更多