我正在完成一个应用程序希望我需要向用户显示他和大约500坐标之间的距离.
使用CLLocation方法计算它,效果很好,但在iPhone 4中大约需要1分钟才能完成每个位置的计算.
最好的方法是什么?用span?还有其他更快的方法吗
谢谢大家,
瑞
I have essentially lifted this code from the internet:
//variables
//location manager
var locationManager:CLLocationManager!
var currentLocation:CLLocation?
//outlets
@IBOutlet weak var whatTextField: UITextField!
@IBOutlet weak var whereTextField: UITextField!
@IBOutlet weak var whenTextField: UITextField!
@IBAction func onCreateEventClick(_ sender: Any) {
let event = CAEvent(eventId: "123777abc", eventName: whatTextField.text, location: currentLocation)
event.save { (error) in
//handle event error
print(error)
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if( CLLocationManager.authorizationStatus() == .authorizedWhenInUse ||
CLLocationManager.authorizationStatus() == .authorizedAlways){
determineCurrentLocation()
} …Run Code Online (Sandbox Code Playgroud) 我希望能够查看用户是否位于 Swift 4 中其他位置的 5 公里半径范围内。
例如:
User Location: 37.785834, -122.406417
Other Location: -117.564011, 48.302353
Run Code Online (Sandbox Code Playgroud)
感谢任何提供帮助的人!
Always Allow当应用程序requestAlwaysAuthorization在 iOS 13 中请求 CLLocationManager中的地理定位时,用户似乎无法获得该选项。它显示为Allow While Using App和Allow Once。
环境:iOS 13 beta 6、Xcode beta 5、iPhone X
如何提示Always Allow用户?
cllocation ×4
ios ×2
swift ×2
distance ×1
geolocation ×1
ios13 ×1
iphone ×1
swift4 ×1
xcode ×1