Last active
August 29, 2015 14:11
-
-
Save lborsato/23748fb69db3c0e9a0c6 to your computer and use it in GitHub Desktop.
iOS - Create tab controller with view controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a tabbar controller and an array to contain the view controllers | |
UITabBarController *tabBarController = [[UITabBarController alloc] init]; | |
tabBarController.delegate = self; | |
NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] init]; | |
// Setup first view and nav controllers | |
UIViewController *vc1 = [[UIViewController alloc] init]; | |
UINavigationController *nc1 = [[UINavigationController alloc] initWithRootViewController:vc1]; | |
[localViewControllersArray addObject:nc1]; | |
// Setup second view and nav controllers | |
UIViewController *vc2 = [[UIViewController alloc] init]; | |
UINavigationController *nc2 = [[UINavigationController alloc] initWithRootViewController:vc2]; | |
[localViewControllersArray addObject:nc2]; | |
// set the tab bar controller view controller array to the localViewControllersArray | |
tabBarController.viewControllers = localViewControllersArray; | |
[self.window setRootViewController:self.tabBarController]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment