简体   繁体   English

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

[英]iOS simulator and XCode to simulate Compass?

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

Compass is not in the list of the hardware interactions supported by the simulator and CLLocationManager headingAvailable reports it's not available on the simulator. Compass不在模拟器支持的硬件交互列表中,并且CLLocationManager headingAvailable报告它在模拟器上不可用。

Also, in this doc: 另外,在这个文档中:

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

Some location services require the presence of specific hardware on the given device. 某些位置服务需要在给定设备上存在特定硬件。 For example, heading information is available only for devices that contain a hardware compass. 例如,标题信息仅适用于包含硬件指南针的设备。 This class defines several methods that you can use to determine which services are currently available. 此类定义了几种可用于确定当前可用服务的方法。

Specifically CLLocationManager has this class property to check if the compass is available: 具体来说,CLLocationManager具有此类属性来检查指南针是否可用:

+ (BOOL)headingAvailable

If I run this under the simulator: 如果我在模拟器下运行:

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

Outputs: 输出:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM