简体   繁体   中英

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.

Also, in this doc:

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:

+ (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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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