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 に答える