【发布时间】:2016-03-07 00:26:03
【问题描述】:
我有一个 iOS 应用程序,它假设当某些事件发生时,无论应用程序是在前台还是后台,都会根据纬度和经度获取手机位置。
当应用程序在前台时,我总能得到准确的位置。
但是,当应用程序在后台运行时,有时我会获得准确的位置,有时会偏离一英里左右。当应用程序在后台运行时,我可以使用什么技巧来获得准确的位置?
这是我的部分代码。
var currentLocation = CLLocation()
var locManager = CLLocationManager()
.
.
locManager.desiredAccuracy = kCLLocationAccuracyBest;
.
.
currentLocation = locManager.location!
var long = String(currentLocation.coordinate.longitude)
var lat = String(currentLocation.coordinate.latitude)
var location = CLLocation(latitude:currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
还有没有办法知道我得到的位置是否准确?
【问题讨论】:
标签: ios swift core-location