我尝试使用代码在 didUpdateLocations 方法中设置 CLCircularRegion
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
NSLog("Location Updated from did Update Locations")
let persist = Persistence()
let currentLocation : CLLocation = locations[0]
let latitude : Double = currentLocation.coordinate.latitude
let Longitude : Double = currentLocation.coordinate.longitude
let regionID = "GeoFenceTrack"
let region : CLCircularRegion = CLCircularRegion.init(center: CLLocationCoordinate2DMake(latitude, Longitude), radius: Double(persist.getObject(mdmiosagent_Constants.LOCATIONRADIUS))!, identifier: regionID)
NSLog("the center of the region is \(region.center) and the redius of the region is \(region.radius)")
self.sendLocation(currentLocation)
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
locationManager.delegate = self
locationManager.startMonitoringForRegion(region)
}
线上发生错误
locationManager.startMonitoringForRegion(region)
并且发生的错误是
********* iPad *******[4018] <Warning>: Failed for region Error Domain=kCLErrorDomain Code=5 "(null)"
坐标和半径正确设置为区域。我也没有监控 20 多个地区。我只监视一个区域。谁能建议我哪里出错了?先感谢您 。