私は現在、4 つのタブを持つタブ バー コントローラーがあり、各タブにナビゲーション コントローラーがあるプロジェクトに取り組んでいます。これらの各ナビゲーション コントローラーには、複数のビュー コントローラーがプッシュされています。
ここや他の場所で多くの投稿を読みましたが、現在、次のことを行っています。
サブクラス化された UITabbarcontroller
- (BOOL)shouldAutorotate
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotate];
}
- (NSUInteger) supportedInterfaceOrientations
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController]supportedInterfaceOrientations];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
各ビューコントローラーで次のように指定すると、これは正常に機能します。
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
これにより、予想どおりポートレートにロックされます。
しかし今、本当の問題が発生します!いずれかのタブの viewcontroller で横向きに回転するように指定すると、正常に動作しますが、タブを変更しても横向きのままであり、これは私たちが望むものではありません!
要約すると、ほぼすべてのビューを特定の向きにロックし、指定した向き (ここでは縦向き) にあるタブを変更できる方法を誰かが解決しましたか?
この投稿iOS 6 UITabBarController supported orientation with current UINavigation controllerも読みましたが、あるコメントでも「これはほとんど機能しています。問題は、タブを縦向きのみのビューに切り替えたときに既に横向きになっている場合です。縦向きに回転すると修正され、横向きに戻ることはありませんが、最初にロードするときに縦向きにする必要があります」これはここでもほとんど同じです..