0

コンパスを特定の場所に向ける必要があるプロジェクトに取り組んでいます。ユーザーがiPhoneを傾けたり移動したりしても、このコンパスは常にこの場所を指す必要があります。場所と現在の方向に対する角度を取得しましたが、コンパスを指すこの機能を実装する方法がわかりません。何か助けてくれますか。

CLLocationDirection direction = newHeading.magneticHeading;
double radians = -direction / 180.0 * M_PI;
//For Rotate Niddle
CGFloat angle = RadiansToDegrees(radians);

double angletothelocation=[self bearingToLocation:destinationLocation];

[self rotateArrowView:arrowView degrees:(angle+radianangle)];

しかし、私は間違った方向に進んでいます。誰かが私にそれを行う方法を提案できますか?前もって感謝します....

4

1 に答える 1

0

私たちのアプリにはまさにあなたが望む機能があります。あなたのコードは少し異なりますが、向きの修正が欠けていると思います:

self.arrow.transform = CGAffineTransformMakeRotation(toRadian((headingFloat+angle) + orientationCorrection));

方向補正は次のとおりです。

- (int)fixOrientation {
    switch ([[UIApplication sharedApplication] statusBarOrientation]) {
        case UIInterfaceOrientationPortrait:
            return 0;
        case UIInterfaceOrientationLandscapeLeft:
            return 90;
        case UIInterfaceOrientationLandscapeRight:
            return 270;
        case UIInterfaceOrientationPortraitUpsideDown:
            return 180;
    }
}
于 2012-08-10T11:15:37.617 に答える