2010-11-18 18 views
1

RootViewControllerによって制御される複数のUIViewControllerでアプリケーションを構築しています。現在、plistではデフォルトでLandscapeRightに設定されています。iPhone:ランドスケープと肖像画のみを表示するアプリ

は私がRootViewControllerにロードすることができ、次のファイルを持っているとしましょう:

  1. IntroView(ONLY風景右)
  2. LandscapeView(ONLY風景右)
  3. PortraitView(ONLYポートレート)

また、RootViewControllerのshouldAutorotateToInterfaceOrientationに次のものを追加しました:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
if ([currentClass class] == PortraitView.class) { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 

} else { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

}

私はPortraitViewにロードし、viewWillAppearで私はこれが適切に今PortraitViewにロードされたが、私の問題をもたらしthis thread

if (self.interfaceOrientation == UIInterfaceOrientationPortrait) { //UIInterfaceOrientationLandscapeRight) {  

    self.view.transform = CGAffineTransformIdentity; 
    self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90)); 
    self.view.bounds = CGRectMake(0.0, 0.0, 320, 480); 
    self.view.center = CGPointMake(240.0f, 160.0f); 

} 


[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 

に似た(以下を追加するまで、そのすべてが順調ですそれは私のPortraitView内に私は2つのサブビューを持っていますが、私は私のビューを回転させたのでUIViewAnimationTransitionFlipFromLeftは実際には左から右への代わりに下から上にフリップします。私は私の人生のために、PortraitViewにポートレートを伝える方法を理解できません。

[[UIDevice currentDevice] orientation]をチェックすると、それは風景の中で私に伝えます。 shouldAutorotateToInterfaceOrientationを使用してポートレートのみに設定しようとすると、ビューが回転してもはや正しくないようになります。

これはうまくいけばうまくいきます。一日中この問題を見てきました。

ありがとうございます!

+0

RootViewControllerのスーパークラスとは何ですか?それは単純なUIViewControllerですか? –

+0

はい、ただUIViewControllerです。私はナビゲーションやタブバーを使用していません。 –

答えて

0

これはわずかに異なります。 UIViewController左から右の代わりに上から下にスワップされた横長モードのサブクラスです。

私にとってうまくいきかったのは、すべての自分のビューを1つの「内部」ビューに追加してから、UIViewControllerの通常のviewの代わりにそれを反転することでした。

[self innerView][self view]の唯一の子であり、そしてすべてのサブビューは、その中にある
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight 
          forView:[self innerView] 
          cache:YES]; 

関連する問題