2010-01-11 6 views

답변

3

표제도의 경우 xy 대신 magneticHeadingtrueHeading 속성을 사용할 수 있습니다. (각도 측정)

호 진북 대하여 trueHeading

.

@property(readonly, nonatomic) CLLocationDirection trueHeading 

토론 (읽기 전용)

이 속성의 값은 지리적 북극 향해 가리키는 호를 나타낸다. 이 속성의 값은 장치의 물리적 또는 인터페이스 방향에 관계없이 항상 장치의 맨 위를 기준으로보고됩니다. 값 0은 true를 나타내고, 90은 동쪽을 의미하고 180은 남은 것을 의미합니다. 음수 값은 제목을 결정할 수 없음을 나타냅니다.

1

시도 :

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

    CLLocationDirection trueNorth = [newHeading trueHeading]; 

    CLLocationDirection magneticNorth = [newHeading magneticHeading]; 

} 

CLLocationDirection이 형식 정의를 두 번이고 그래서 당신도의 진정한 자성 제목을 얻는다.

+0

true는 유효한 변수 이름이 아닙니다. –

1

이것은 나침반 이미지로 uiimageview를 회전 한 방법입니다. 북쪽 바늘은 원래 이미지에서 위쪽을 향하고있었습니다.

if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
      NSLog(@"UIInterfaceOrientationLandscapeLeft"); 
      [self.compassImageViewIphone setTransform:CGAffineTransformMakeRotation((((newHeading.magneticHeading - 90) *3.14/180)*-1))]; 

     }else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
      NSLog(@"UIInterfaceOrientationLandscapeRight"); 
      [self.compassImageViewIphone setTransform:CGAffineTransformMakeRotation((((newHeading.magneticHeading + 90) *3.14/180)*-1))]; 

     }else if (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){ 
      NSLog(@"UIInterfaceOrientationPortraitUpsideDown"); 
      [self.compassImageViewIphone setTransform:CGAffineTransformMakeRotation((((newHeading.magneticHeading + 180) *3.14/180)*-1))]; 

     }else{ 
      NSLog(@"Portrait"); 
      [self.compassImageViewIphone setTransform:CGAffineTransformMakeRotation((newHeading.magneticHeading *3.14/180)*-1)]; 
     }