Appleによれば、UINavigationController
とUITabBarController
をコードを使用して組み合わせることができます。この設定でタブバーごとに個別のUINavigationControllerを使用する必要があります
MyViewController1* vc1 = [[MyViewController1 alloc] init];
MyViewController2* vc2 = [[MyViewController2 alloc] init];
MyViewController3* vc3 = [[MyViewController3 alloc] init];
MyNavRootViewController* vc4 = [[MyNavRootViewController alloc] init];
UINavigationController* navController = [[UINavigationController alloc]
initWithRootViewController:vc4];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, navController, nil];
tabBarController.viewControllers = controllers;
、唯一VC4はUINavigationController
を持っていますが、私は、VC1~VC3をしたい場合もUINavigationController
を持って何?、私のような行う必要があります。..
MyViewController1* vc1 = [[MyViewController1 alloc] init];
UINavigationController* nv1 = [[UINavigationController alloc]
initWithRootViewController:vc1];
MyViewController1* vc2 = [[MyViewController2 alloc] init];
UINavigationController* nv2= [[UINavigationController alloc]
initWithRootViewController:vc2];
MyViewController1* vc3 = [[MyViewController3 alloc] init];
UINavigationController* nv3 = [[UINavigationController alloc]
initWithRootViewController:vc3];
NSArray* controllers = [NSArray arrayWithObjects:nv1, nv2, nv3, nil];
tabBarController.viewControllers = controllers;
はこれです正しいアプローチ?
これはあなたが望むものであるかどうかによって決まります...私はアプローチが間違っているとは言いませんが、おそらくそれはあなたが期待するかもしれない結果を与えないかもしれません。あなたの目標は何ですか? – Saphrosit
複数のビューを1つのTabでナビゲートする必要がある場合は、navigationControllerを使用する必要があります。単一のViewControllerをTabごとに表示する場合は、navControllerを使用しないでください。それはあなたの要求が何であるかによって異なります。 –