iOS模拟器和XCode模拟指南针?

时间:2011-11-09 02:34:07

标签: iphone objective-c ios xcode core-location

我知道现在有一种模拟位置的方法,但有没有办法模拟罗盘值?

1 个答案:

答案 0 :(得分:8)

指南针不在模拟器支持的硬件交互列表中,而且CLLocationManager headingAvailable报告它在模拟器上不可用。

另外,在本文档中:

http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html

  

某些位置服务需要具有特定硬件   给定的设备。例如,标题信息仅可用   适用于包含硬件指南针的设备。这个类定义   您可以使用几种方法来确定哪些服务   目前可用。

具体来说,CLLocationManager具有此类属性来检查指南针是否可用:

+ (BOOL)headingAvailable

如果我在模拟器下运行:

NSLog(@"headingAvailable: %d", (int)[CLLocationManager headingAvailable]);

输出:

2011-11-08 22:38:26.873 Craplet[39975:b603] headingAvailable: 0