ルートと詳細の2つのビューコントローラーがあります。ルートビューコントローラは横向きと縦向きをサポートしているため、次のコードがあります。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
上記のコードは、ルートビューコントローラーに対して完全に機能します。
ルートビューコントローラーが表示されていて、ユーザーがデバイスを横向きモードに回転させると、それに応じてビューが調整されます。この時点から、詳細ビューコントローラをスタックにプッシュすると、ランドスケープモードでロードされます。しかし、ポートレートモードのみをサポートするように構成しているので、そうすべきではありません。詳細ビューコントローラーで以下のコードを使用しています。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}