没有网络时不调用CLLocationManagerDelegate -locationManager(_:startMonitoring :)

时间:2018-12-04 08:32:25

标签: ios iphone swift core-location cllocationmanager

当我在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)

1 个答案:

答案 0 :(得分:1)

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