2012-01-12 17 views
0

私のアプリでは、ユーザーがさまざまなviewControllerを通して進めるナビゲーションスタックがあります。いくつかのビューは複数の方向付けをサポートしていますが、ビューの1つはそうではありません。だから私の質問は、1つの特定のUIViewControllerを1つの方向でのみ表示させることができます。最初にビューが読み込まれたときと別のビューがポップオフされ、このビューが再び表示されるときの両方で動作するようにする必要があります。おかげUIViewControllerに一定の向きを強制的に適用させよう

私は、ビューの回転を制御するには、この2つのメソッドを実装します。

-(void)orientationDidChange:(NSNotification *)notification 
-(BOOL)shouldAutoRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

おかげ

+0

上記のデリゲートメソッドの実装を投稿できますか? –

+0

この質問は以前に何回も聞かれました:http://stackoverflow.com/questions/3538796/how-to-force-horizo​​ntal-orientation要するに、メソッドをオーバーライドし、戻り値を変更して、必要な方向のみをサポートします。 – aqua

+0

私は尋ねる前にそれを試しました。 – Andrew

答えて

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
0

回答:shouldAutoRotateToInterfaceOrientation方法UIViewControllerクラスの。

UIViewで向きがサポートされている場合、この関数はYESを返します。 をlandscape orientationに限定すると、そのビューをロードするたびに自動的にiPhone/iPadがその向きになります。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationLandscape); 
} 
関連する問題