【问题标题】:iOS simulator and XCode to simulate Compass?iOS模拟器和XCode模拟指南针?
【发布时间】:2011-12-24 23:23:25
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    Compass 不在模拟器支持的硬件交互列表中,并且 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
    

    【讨论】:

      猜你喜欢
      • 2012-11-06
      • 1970-01-01
      • 2022-11-02
      • 2013-06-10
      • 1970-01-01
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多