0

ビュー内にいくつかの画像があります。回転すると、CGAffineTransformTranslate&Rotateを使用して画像が適切に配置されます。

ただし、PortraitUpsidedownで起動すると、私が定義した翻訳が行われます。

"-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{"メソッド。

この平行移動は、デバイスの向きが変わったときにのみ実行する必要があります。この翻訳がLaunchで行われないようにするにはどうすればよいですか?

編集:

viewWillAppearメソッドの実装に関するヒントの後も、まだ問題があります。

これが私のプロジェクトのコードです。

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

    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
       toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

        image1.transform = CGAffineTransformTranslate( image1.transform, -65.0, 255.0);
        image2.transform = CGAffineTransformTranslate( image2.transform, -65.0, 255.0);
    }
    else {

        image1.transform = CGAffineTransformIdentity;
        image2.transform = CGAffineTransformIdentity;
    }

}

-(void) viewWillAppear:(BOOL)isRotated{

    isRotated = FALSE;
}

しかし、私が定義するコードをどのように実装すればよいですか?

isRotated = TRUE;

ご協力いただきありがとうございます !

4

1 に答える 1

0

shouldAutorotateToInterfaceOrientationデリゲート メソッドを使用します。

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

変数を設定しBOOLます。インターフェースYESが使用CGAffineTransformTranslateおよび回転に必要なものである場合に作成するか、そこからメソッドを呼び出して翻訳します。

お気に入り:

if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    // do something
于 2011-03-14T10:26:19.183 に答える