2

私は自分のアプリケーションの背景画像として UIImageView を持っています。これは、遭難したヘリコプターのように自動回転します。問題は、向きが自動回転すると、画像があちこちに移動し、気に入らないことです。これは単純なテクスチャなので、ユーザーは自動回転ではなく、その場所にとどまることを好むと思います。これが意味することは、画像を全画面表示のままにしたいということです。ユーザーが電話を回転させると、画像は 90 度回転するだけなので、画像は電話で静止しているように見えますが、アプリケーションの残りの部分ではありません。

4

2 に答える 2

1

willAnimateRotationToInterfaceOrientation:duration:ビューコントローラーにメソッドを実装しUIImageViewて、反対方向に回転させることができます。

以下のコードは私の頭の上からのものであり、それが機能することを保証することはできません:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
    CGFloat angle = M_PI/2; // Figure out the proper angle
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    imageview.transform = CGAffineTransformMakeRotation(angle);
    [UIView commitAnimations];
}
于 2010-07-05T22:30:41.317 に答える
0

画像編集ソフトウェアで画像を回転させ、動的にロードすることをお勧めします。これは、角度をいじるよりもはるかに簡単です (また、コードが読みやすくなります)。

このような:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {

        myBackground.image = [UIImage imageNamed:@"bg.jpg"];            

    } else { // landscape view      

        myBackground.image = [UIImage imageNamed:@"bg_landscape.jpg"];

    }
}
于 2010-11-26T09:24:31.763 に答える