CLFloor返回级别2146959360?

问题描述 投票:0回答:1

我正在使用CLLocationManager,查看CLLocationManager属性并检查locationlocation(如果有)。该文档建议,如果无法确定level,则只会返回level。实际上,我得到的是floor实例,但其floor是2146959360。将其转换为十六进制的0x7FF80000,看起来可疑地像一些神秘的前哨值。

floor

我仅在物理iOS 13.3.1设备上看到此行为。 FWIW,较旧的iOS版本(我只在这里安装了iOS 10设备)看上去像模拟器一样返回nil

发生了什么事?

ios iphone mapkit cllocation clfloor
1个回答
0
投票

如果您呼叫CLFloor,此问题将消失。如果这样做,则level属性将为lazy var locationManager: CLLocationManager = { let locationManager = CLLocationManager() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest return locationManager }() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) switch CLLocationManager.authorizationStatus() { case .notDetermined: locationManager.requestWhenInUseAuthorization() case .denied: redirectToSettings() default: break } } @IBAction func didTapGetLocation(_ sender: Any) { updateLabels(for: locationManager.location) } func updateLabels(for location: CLLocation?) { guard let location = location else { floorLabel.text = "No location." return } if let floor = location.floor { let hexString = "0x" + String(format: "%08x", floor.level) floorLabel.text = "\(floor.level) (\(hexString))" } else { floorLabel.text = "No floor." } } nil值为2146959360(0x7FF80000)的startUpdatingLocation实例仅在您查询startUpdatingLocationfloor而没有首先调用floor时出现。

文档建议此nil属性使用最后一个已知值填充。无论如何,CLFloor应该为level(至少对于我的特定位置),但不是。 level无效。

请参见location,以举例说明错误的表现以及如何调用CLLocationManager

startUpdatingLocation

我已提交了错误报告(FB7638281)。

© www.soinside.com 2019 - 2024. All rights reserved.