繁体   English   中英

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

[英]CLLocationManagerDelegate -locationManager(_:startMonitoring:) not called when there is no network

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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