以下を試してください。うまくいかない理由がわからない
1)
.plist ファイルでキー UIInterfaceOrientation を UIInterfaceOrientationLandscapeRight に設定します
2) UITabBarController shouldAutorotateToInterfaceOrientation() メソッドをオーバーライドします。次のコードは、タブ 0 と 1、および 1 つのコントローラーのみを扱います。ナビゲーション コントローラーがあり、スタック上にある可能性のあるさまざまなコントローラーを制御したい場合は、それに応じてコードを変更する必要があります。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
BOOL tabZeroController = [[[self.viewControllers objectAtIndex:0] visibleViewController] isKindOfClass:[YourTabZeroTableViewController class]];
BOOL tabOneController = [[[self.viewControllers objectAtIndex:1] visibleViewController] isKindOfClass:[YourTabOneTableViewController class]];
if(self.selectedIndex == 0 && tabZeroController)
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
if(self.selectedIndex == 1 && tabOneController)
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
return NO;
}
2) 設定
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
デリゲートの applicationDidFinishLaunching() メソッドでは、デバイスではなく、シミュレーターにのみ必要です
3) コントローラーに次の shouldAutorotateToInterfaceOrientation(method) を追加します
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
4) デバイスでアプリを実行し、[ハードウェア] メニュー項目の [左に回転] と [右に回転] を使用して、正しく動作することを確認します。横向きモードでディスプレイが表示されるはずです。