Niestandardowy kontroler UITabBarController i UINavigationController
Opracowuję aplikację na iOS5 i nowsze wersje, nie używam storyboardów ani IB. Tworzę zwyczajUITabBarController
i w moimAppDelegate
Umieszczam w nim 4 kontrolery widoku z tylko 1UINavigationController
(nie mogę powiedzieć dlaczego).
Powoduje to zachowanie, w którym mogę wypchnąć nowy VC tylko zpierwszy zakładka, która najwyraźniej jest zapakowana wUINavigationController
nazywanavController
:
SGTabBarController *tabBarController = [[SGTabBarController alloc] init];
SGHomeViewController* vc1 = [[SGHomeViewController alloc] init];
SGChooseOSAgainViewController* vc3 = [[SGChooseOSAgainViewController alloc] init];
SGSmsServicesViewController* vc4 = [[SGSmsServicesViewController alloc] init];
SGSupportViewController *vc5 = [[SGSupportViewController alloc] init];
navController = [[UINavigationController alloc] initWithRootViewController:vc1];
NSArray* controllers = [NSArray arrayWithObjects:navController, vc3, vc4, vc5, nil];
tabBarController.viewControllers = controllers;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = tabBarController;
[navController setNavigationBarHidden:YES animated:NO];
[self.window makeKeyAndVisible];
Dlaczego? Czy powinienem stworzyć osobnyUINavigationController
dla każdej karty? Zrobiłem ten kod z dokumentacji Apple.