如何在iOS上检测指南针校准开关状态

如何在iOS上检测指南针校准开关状态,ios,core-location,cllocationmanager,heading,Ios,Core Location,Cllocationmanager,Heading,我目前正在使用CLLocationManager,希望了解设备的当前标题。到目前为止,一切都很好,功能已经实现,现在我尝试完善我的应用程序 有一个极端情况,如果用户关闭用户设置标题中的指南针校准标志,更新将不再发送到我的应用程序。在这种情况下,我想给用户一些反馈,他必须再次打开指南针校准,否则我的应用程序将无法工作 我发现如果用户关闭我的应用程序的定位服务,我仍然会收到磁航向。但是如果用户关闭“指南针校准”设置,我将不再收到任何航向更新。但是如何通过CoreLocation框架识别“指南针校准”

我目前正在使用
CLLocationManager
,希望了解设备的当前标题。到目前为止,一切都很好,功能已经实现,现在我尝试完善我的应用程序

有一个极端情况,如果用户关闭用户设置标题中的
指南针校准
标志,更新将不再发送到我的应用程序。在这种情况下,我想给用户一些反馈,他必须再次打开指南针校准,否则我的应用程序将无法工作

我发现如果用户关闭我的应用程序的
定位服务
,我仍然会收到磁航向。但是如果用户关闭“指南针校准”设置,我将不再收到任何航向更新。但是如何通过
CoreLocation
框架识别“指南针校准”已关闭

CLLocationManagerDelegate
”通过

- (void)locationManager:(CLLocationManager*)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status 
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
方法。但状态仅在“位置服务”对于我的应用处于-/活动状态时才显示

我还试图通过网络获取一些有效的信息

- (void)locationManager:(CLLocationManager*)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status 
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
委托
方法,但未成功


CoreLocation
框架中是否有东西可以告诉我是否打开/关闭了“指南针校准”标志。

根据我的发现,
newHeading.trueHeading
locationManager:didUpdateHeading:
中,如果指南针校准关闭,则应为
-1
。这应该做到:

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    if(newHeading.trueHeading == -1)
        //Compass calibration is off provided location services are on for the app
}

你找到答案了吗?谢谢!这正是我需要的。我没有在我的应用程序中直接使用航向(我使用的是Core Motion),因此我甚至没有实现
didUpdateHeading
方法,也没有像我应该的那样仔细查看相应的文档。但是请注意,在启动一段时间内,即使启用了指南针校准,trueHeading也是-1。