import UIKitimport Foundationimport CoreLocationclass VIEwController: UIVIEwController,CLLocationManagerDelegate {let manager = CLLocationManager()var currentSpeed = 0.0overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() manager.requestWhenInUseAuthorization() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyHundredMeters manager.startUpdatingLocation()}func locationManager(manager: CLLocationManager,dIDUpdateLocations locations: [CLLocation]) { print(manager.location?.speed)}func locationManager(manager: CLLocationManager,dIDFailWithError error: NSError) { print("Error: \(error.localizedDescription)")}
唯一的问题是它打印“Optional(-1,0)”
我在这里先向您的帮助表示感谢.
解决方法 如果设备没有移动,或者移动得足够慢以至于数学没有意义,Core Location会给你一个负速度值.https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/#//apple_ref/occ/instp/CLLocation/speed
总结以上是内存溢出为你收集整理的swift – CoreLocation用户速度全部内容,希望文章能够帮你解决swift – CoreLocation用户速度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)