2011-08-05 23 views
1

私はIF文を使用して、デバイスの向きがいつ変化するかを検出し、それが起こると、新しいビューが表示され、1つのポートレート、もう1つのランドスケープが表示されます。唯一の問題は、私がポートレートから風景に回転し、風景ビューが示す場合、それはすべての方法で回転していないことです。まだ肖像画になっていて、90度の角度になっています。ご協力いただきありがとうございます!ビューが正しく回転しない

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

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

     self.view = portrait; 


    } else { 
     //landscape 

     self.view = landscape; 

    } 

} 

答えて

1

Appleが提供するサンプルコードはhereです。

+0

完璧、ありがとう! –

0

その後、didRotateFromInterfaceOrientationに後で新しいビューを押して、willRotateToInterfaceOrientation中に目的地の方向を格納することによって、それを修正することができるかもしれません。

+0

これはどうしたらいいですか? self.view = UIInterfaceOrientationPortraitと似たようなもの|| UIInterfaceOrientationPortraitUpsideDownなど?ご協力いただきありがとうございます! –

関連する問題