2011-08-16 1 views
1

私はMainWindow.xibファイルを持っています。私はMainWindowLandscape.xibである2番目の.xibファイルを探します。私は多くの.xibファイルを持っており、私はポートレートと風景を別々にデザインしています。とにかくeasly Interface Orientationを変更するにはどうしますか?

MainWindow.xibとMainWindowLandscape.xib(UITabbarControllerベース)でそれらを割り当てたいのですが、MainWindow.xibでポートレートビューを割り当て、MainWindowLandscape.xibで風景ビューを割り当てます。それは可能か、最も簡単な方法は何ですか?

すべてのビュー(ポートレートとランドスケープ)は、同じことをお互いに行います。 UIのみが変更されます。

ありがとうございます。

答えて

1

次の2つのXIBファイルに関連付けられたビューコントローラに

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 

をオーバーライドしていることを行うことができます。

具体的には、場合にあなたは、常に肖像する方向を強制したい操作を行います。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation  { 
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) 
     return YES; 
    return NO; 
} 

あなたは常に風景の中に表示するようにビューコントローラを強制したい:

一度
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation  { 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) 
     return YES; 
    return NO; 
} 

コントローラーが自動的に回転するのは、条件が満たされた場合のみです。具体的には、タブバーコントローラの場合、すべて内部コントローラが所定の方向をサポートしている必要があります(つまり、上記のようにshouldAutorotateToInterfaceOrientationを実装する必要があります)。

+0

これがあなたが提案しているものかどうかは分かりませんが、 '-shouldAutorotateToInterfaceOrientation:'の結果は動的に変更してはいけません。 – jtbandes

+0

@jtbandes:私の 'shouldAutorotateToInterfaceOrientation'実装はかなり静的です。各実装はコントローラタイプに特有ですが、明確でない場合は – sergio

+0

Ah ok。私はちょうどあなたが「風景を強制したい時」を誤解しました。 – jtbandes

関連する問題