Swift3 CoreLocation:LocationManager.StopUpdatengLocation()不工作
我试图理解为什么在我调用StopUpdateLocation()之后locationManager继续提供更新Swift3 CoreLocation:LocationManager.StopUpdatengLocation()不工作,swift3,core-location,Swift3,Core Location,我试图理解为什么在我调用StopUpdateLocation()之后locationManager继续提供更新 扩展操作视图控制器:CLLocationManagerDelegate{ func locationManager(manager:CLLocationManager,didUpdateLocations位置:[CLLocation]){ 让newLocation:CLLocation=locations.last! 打印(“新位置精度为:\(newLocation.Horizonta
扩展操作视图控制器:CLLocationManagerDelegate{
func locationManager(manager:CLLocationManager,didUpdateLocations位置:[CLLocation]){
让newLocation:CLLocation=locations.last!
打印(“新位置精度为:\(newLocation.HorizontalAccurance)”)
打印(“所需精度为:\(locationManager.desiredAccuracy)”)
如果newLocation.HorizontalAccurance<0{
返回
}
如果newLocation.HorizontalAccurance我花了很多时间寻找答案,我相信我已经找到了。显然,在打电话给stopUpatingLocation后,GPS天线需要几秒钟才能关机。有人发帖说这是在WWDC讨论的
我花了很多时间寻找答案,我相信我已经找到了。显然,在呼叫Stoppatinglocation后,GPS天线需要几秒钟才能断电。有人发帖说这是在WWDC讨论的
我认为您应该调用管理器.stopUpdateLocation()
而不是位置管理器.stopUpdateLocation()
。恐怕不行。您确定我们正在关闭位置管理器吗
已打印?是的。它已打印多次,这是问题的核心。它是否会在一段时间后停止报告位置?我认为您应该调用管理器。StopUpdateLocation()
而不是locationManager.StopUpdateLocation()
。恐怕这不起作用。您确定“我们正在关闭位置管理器”
已打印?是的。打印了多次,这是问题的核心。是否会在短时间后停止报告位置?
extension ActionViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let newLocation: CLLocation = locations.last!
print("New Location Accuracy is: \(newLocation.horizontalAccuracy)")
print("Desired Accuracy is: \(locationManager.desiredAccuracy)")
if newLocation.horizontalAccuracy < 0 {
return
}
if newLocation.horizontalAccuracy <= locationManager.desiredAccuracy {
print("We are shutting down location manager")
locationManager.stopUpdatingLocation()
currentLocation = newLocation
let camera = GMSCameraPosition.camera(withLatitude: newLocation.coordinate.latitude,
longitude: newLocation.coordinate.longitude,
zoom: zoomLevel)
...