【发布时间】:2011-09-12 05:19:21
【问题描述】:
我在 iPhone/iPad 指南针开发上遇到了一些问题。
从 CLHeading 获取的 trueHeading 总是给我“-1”值,我被困在这里。这是我的代码:
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.delegate = self;
self.locationManager.headingFilter = 0.5; //1 degrees
[self.locationManager startUpdatingHeading];
我还发现了一件事,那就是当我在地图应用程序或指南针应用程序上使用了位置信息时,trueHeading 值突然读取正确。我想知道是什么原因,有什么想法吗?它发生在 iPhone4 和 iPad 上。
每当我在设置中关闭定位服务并重新启用它时也会发生这种情况,它将无法读取正确的 trueHeading 值,我想知道是因为我创建的应用程序无法启用定位服务吗?
还是先谢谢了
---我的解决方案---
见下文。
【问题讨论】:
-
您是在有指南针的设备(例如 iPhone 4)上执行此操作吗?
-
如果你勾选[CLLocationManager headingAvailable],它会返回什么?
标签: iphone ios ipad compass-geolocation