これを行うにはいくつかの方法があります。他のものよりも優れているものもありますが、ほとんどの場合、特定の状況のニーズによって異なります。
rootViewControllerローテーション中に述べたように交換してください。
- ポートレートとランドスケープの間で回転するときは、常にa
UISplitViewControllerを使用し、seguetoを使用してreplaceを置き換えます。detailViewController
addChildViewController:およびを使用して回転時に適切なViewControllerを追加/削除するカスタムコンテナViewControllerを使用/作成します。removeFromParentViewController:
選択肢3の非常に大雑把な例。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self.childViewControllers[0].view removeFromSuperView];
[self.childViewControllers[0] removeFromParentViewController];
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
[self addChildViewController:portraitVC];
[self.view addSubview:portraitVC.view];
} else {
[self addChildViewController:landscapeVC];
[self.view addSubview:landscapeVC.view];
}
}
あなたが言ったことから、私はオプション3が最適だと思います。とはいえ、View Controllerを切り替える必要があると完全に確信しているわけではありませんが、View ControllerがECSlidingViewController何を提供するのかよくわからないため、確信が持てません。