2

我正在为 iphone 3GS 开发一个指南针应用程序。我已将 CoreLocation 框架用于我使用的指南针方法...

 - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading

...获取标题的方法。

我的问题是如何在不移动 iphone 的情况下获得像“315° NW,90° E,140° SE”这样的值。我没有 3GS iphone 所以,如果有人有什么想法,请帮助。

谢谢你。

4

1 回答 1

1

@implementation我在需要我的假标题和位置数据的类之前使用这个片段。

#if (TARGET_IPHONE_SIMULATOR)
@interface MyHeading : CLHeading
    -(CLLocationDirection) magneticHeading;
    -(CLLocationDirection) trueHeading;
@end

@implementation MyHeading
    -(CLLocationDirection) magneticHeading { return 90; }
    -(CLLocationDirection) trueHeading { return 91; }
@end

@implementation CLLocationManager (TemporaryLocationFix)
- (void)locationFix {
    CLLocation *location = [[CLLocation alloc] initWithLatitude:55.932 longitude:12.321];
    [[self delegate] locationManager:self didUpdateToLocation:location fromLocation:nil];

    id heading  = [[MyHeading alloc] init];
    [[self delegate] locationManager:self didUpdateHeading: heading];
}

-(void)startUpdatingHeading {
    [self performSelector:@selector(locationFix) withObject:nil afterDelay:0.1];
}

- (void)startUpdatingLocation {
    [self performSelector:@selector(locationFix) withObject:nil afterDelay:0.1];
}
@end
#endif
于 2012-02-10T12:03:31.850 回答