LocationManager didEnterRegion未被调用(再次)



我正在尝试注册区域,以便在用户输入它们时得到通知。这是我使用的代码:

public func locationManager(manager:CLLocationManager, didEnterRegion region:CLRegion){
    print("did enter region (region)")
    let regionPalina=region.identifier;
    if regionPalina==palina{
        regionMonitoringCompletion?()
    }
}
public func locationManager(manager: CLLocationManager, monitoringDidFailForRegion region: CLRegion?, withError error: NSError){
        print(error.localizedDescription)
}
let myLocationManager=CLLocationManager()
func startMonitoringForRegion(completion:(Void->Void)){
    regionMonitoringCompletion=completion;
    myLocationManager.delegate=self
    if !monitoredForRegion{
        myLocationManager.startMonitoringForRegion(self.regionForPalina())
        monitoredForRegion=true
    }
}
public func locationManager(manager: CLLocationManager, didStartMonitoringForRegion region: CLRegion){
    print("region: (region) registered")
    print(myLocationManager.monitoredRegions)
}
public func locationManager(manager: CLLocationManager, didDetermineState state: CLRegionState, forRegion region: CLRegion){
    print("state transition (state)")
}
func stopMonitoringForRegion(){
    myLocationManager.delegate=nil
    regionMonitoringCompletion=nil
    if !monitoredForRegion {
        myLocationManager.stopMonitoringForRegion(self.regionForPalina())
        monitoredForRegion=false
    }
}

注册似乎很顺利,因为调用了didStartMonitoringForRegion,并且它正确地打印了monitoredRegions。然而,既没有调用didEnterRegion,也没有调用didDetermineState,甚至没有调用monitoringDidFailForRegion。

这可能是什么生意?

我最终用用户位置模拟了这些东西。

相关内容

  • 没有找到相关文章

最新更新