質問

アプリケーションの背景画像としてUIImageViewを持っています。これは、苦しんでいるヘリコプターのように、オートオート化されています。問題は、オリエンテーションが私のイメージがあちこちにシフトされ、私はそれが好きではないときです。それはシンプルなテクスチャーなので、ユーザーはオートロテートではなく、その場所にとどまることを好むと思います。これが意味するのは、画像をフル画面にとどめることを望み、ユーザーが電話を回転させると、画像が90度回転しているので、アプリケーションの残りの部分ではなく、電話で画像が静的であるように見えるということです。

役に立ちましたか?

解決

実装してみてください 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];
}

他のヒント

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

このような:

- (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"];

    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top