import UIKitimport CoreLocationclass VIEwController: UIVIEwController,CLLocationManagerDelegate { @IBOutlet var latLabel: UILabel! @IBOutlet var longLabel: UILabel! @IBOutlet var courseLabel: UILabel! @IBOutlet var speedLabel: UILabel! @IBOutlet var altLabel: UILabel! @IBOutlet var addressLabel: UILabel! var manager:CLLocationManager! var userLocation:CLLocation = CLLocation() overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() manager = CLLocationManager() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyBest manager.requestWhenInUseAuthorization() manager.distanceFilter = 50 manager.startUpdatingLocation() } func locationManager(manager: CLLocationManager!,dIDUpdateLocations locations: [AnyObject]!) { userLocation = locations[0] as CLLocation println(userLocation.coordinate.latitude) var latitude:CLLocationdegrees = userLocation.coordinate.latitude latLabel.text = "\(latitude)" var longitude:CLLocationdegrees = userLocation.coordinate.longitude longLabel.text = "\(longitude)" var course:CLLocationDirection = userLocation.course courseLabel.text = "\(course)" var speed:CLLocationSpeed = userLocation.speed speedLabel.text = "\(speed)" var altitude:CLLocationAccuracy = userLocation.altitude altLabel.text = "\(altitude)" CLGeocoder().reverseGeocodeLocation(userLocation,completionHandler: { (placemarks,error) -> VoID in if (error != nil) { println(error) } else { if let p = CLPlacemark(placemark: placemarks?[0] as CLPlacemark) { println(p) } } }) //println("Location = \(locations)") println(locations) }}
我一直收到此错误错误域= kCLErrorDomain Code = 2“ *** 作无法完成.(kCLErrorDomain错误2.)”当我尝试获取用户最近的地址时.我不确定问题是什么,有人能看到发生了什么吗?谢谢.
解决方法 根据 the docs,这是一个网络错误,CLGeocoder需要一个有效的网络连接,以便对一个位置进行地理编码.此外,CLGeocoder将限制地理编码请求,如果超过请求率,则返回相同的错误,这也在类引用中记录.
总结以上是内存溢出为你收集整理的ios – 错误域= kCLErrorDomain代码= 2“无法完成 *** 作. (kCLErrorDomain错误2.)“全部内容,希望文章能够帮你解决ios – 错误域= kCLErrorDomain代码= 2“无法完成 *** 作. (kCLErrorDomain错误2.)“所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)