更改当前CLLocationManager的distanceFilter

时间:2015-09-07 15:40:22

标签: ios ios8 cllocationmanager

想要从didUpdateLocations内部更改当前CLLocationManager的距离过滤器。没有变化。

override func viewDidLoad()
{
    super.viewDidLoad()

    ...

    self.locManager = CLLocationManager()
    if (self.locManager.respondsToSelector(Selector("requestAlwaysAuthorization")))
    {
        self.locManager.requestAlwaysAuthorization()
    }

    if CLLocationManager.locationServicesEnabled()
    {
        self.locManager.delegate = self
        self.locManager.desiredAccuracy = kCLLocationAccuracyBest
        self.locManager.distanceFilter = Double(100)
        self.locManager.startUpdatingLocation()
    }

    ...

    }

根据设备速度和其他属性在didUpdateLocations中更改desiredFilter。

 func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)
{
...
     self.locManager.distanceFilter =  Double(desiredFilter)
...
}

0 个答案:

没有答案