2010-01-12 3 views
2

iPhone 3GS 용 나침반 응용 프로그램을 개발 중입니다. 나는 ... 내가 사용했던 나침반 방법에 대한 CoreLocation 프레임 워크를 사용하고 iPhone Compass 프로그래밍

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

... 제목을 가져 오는 방법.

제 질문은 아이폰을 움직이지 않고 "315 ° NW, 90 ° E, 140 ° SE"와 같은 값을 얻는 방법입니다. 3GS 아이폰이 없기 때문에 누군가 아이디어가 있다면 제발 도와주세요.

감사합니다.

+1

보유하지 않았거나 테스트 할 수없는 장치 용 응용 프로그램을 개발하는 것은 좋지 않습니다. iPhone 3G S 용으로 제작하는 경우 이동해야합니다. –

+0

나는 당신이 무엇을 요구하고 있는지 잘 모르겠습니다. 귀하의 질문을 조금 명확히 할 수 있습니까? CLHeading 객체에서 나침반 머리글을 추출하는 방법을 묻는다면 trueHeading 또는 magneticHeading 속성을 살펴보십시오. –

+0

아니요, 사용자가 시작 버튼을 누른 후 나침반 이벤트가 시작되고 화살표가 315 ° NW, 90 ° E, 140 ° SE 등의 고정 된 지점으로 이동하면 직선을 가리키는 화살표가 있습니다. 좌표를 어떻게 감지해야합니까? 위에 주어진 것입니다. 고마워요. – shivang

답변

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 
관련 문제