I know I can do this
[self.navigationController pushViewController:self.someUITabBarController animated:YES];
And that means putting UITabBarController
on a navigationgContr开发者_运维技巧oller
somehow
What about if I want someUITabBarController
to be the first controller (the one located on the lowest level) of navigationController
?
I simply cannot change the rootViewController
of the NavigationController
into someUITabBarController
Erm not sure this is what you want. Below this code will be put under the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
in you "appDelegate" class.
UITabBarController *tabController = [[UITabBarController alloc] init];
UIViewController *viewController1 = ...
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1];
NSArray *controllers = [NSArray arrayWithObjects:navigationController, nil]; // can add more if you want
[tabController setViewControllers:controllers];
// this is for custom title and image in the tabBar item
navigationController.tabBarItem.title = @"abc";
[navigationController.tabBarItem setImage:[UIImage imageNamed:@"abc.png"]];
self.window.rootViewController = tabController; // or [self.window addSubview: tabController.view];
[self.window makeKeyAndVisible];
I am not sure if this works. But try this,
UINavigationController *navCont = [[UINavigationController alloc] init];
[navCont pushViewController:navCont animated:NO];
精彩评论