swift - 无法从核心位置回调请求指南针校准
问题描述
我在我的应用程序中使用核心位置,并且在设备罗盘/航向值太不精确时尝试显示校准警报。
我正在从 didUpdateHeading 委托函数中正确读取标题值。
我阅读了相关帖子和 CLLocationManager 文档(https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/1621457-locationmanagershoulddisplayhead)。
在 locationManagerShouldDisplayHeadingCalibration(_:) 委托函数中,我尝试了这两种实现:
func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool {
return true
}
和:
func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool {
print("locationManagerShouldDisplayHeadingCalibration")
if let h = manager.heading {
return h.headingAccuracy < 0 || h.headingAccuracy > 10
}
return true
}
在文档中,声明“如果您从此方法返回 false 或未在您的委托中为其提供实现,则核心位置不会显示航向校准警报。即使未显示警报”,但我没有不知道如何“为其提供实现”。
此外,我发现没有办法手动显示系统校准警报,如果警报没有按我想要的频率显示,那么轮询 didUpdateHeading 回调中的 headingAccuracy 值并显示类似系统的方法是否是一个很好的解决方案警报 ?另外,我从未见过有什么方法可以触发系统校准警报?
解决方案
推荐阅读
- java - Springboot递归方法为Async
- android - Jetpack Compose:Modifier.heightIn(...) 与 Modifier.prefferedHeigh(...) 有什么区别
- regression - 使用像梯度提升这样的线性回归
- sql - Oracle 数据库中的 VARCHAR
- python - discord.py:在启动时运行命令
- c - AddressSanitizer:堆栈使用后范围
- python - 在Python中同时从列表中获取随机值及其位置
- c++ - Codeblocks 20.3 和 minGW_x64_Win_Build 之间有什么问题?
- javascript - Angular - 如何动态下载 Json 文件
- css - Django + Svelte 样式不起作用,MIME 类型('text/html')不是受支持的样式表 MIME 类型