Created
August 3, 2012 05:50
-
-
Save seansullivan/3244870 to your computer and use it in GitHub Desktop.
Set up navigation inside view controller
This file contains hidden or 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
// Note-- @interface ContainingViewController : UIViewController <UINavigationControllerDelegate, UITabBarControllerDelegate> | |
-(void) setUpNav { | |
// create tab bar controller and array to hold the view controllers | |
UITabBarController *tabBarController = [[UITabBarController alloc] init]; | |
[tabBarController.view setFrame:CGRectMake(0, 0, 300, 100)]; | |
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:1]; | |
UIViewController *view1 = [[UIViewController alloc] init]; | |
view1.title = @"View 1"; | |
view1.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0]; | |
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:view1]; | |
firstNavController.navigationBar.barStyle = UIBarStyleBlack; | |
firstNavController.delegate = self; | |
[localControllersArray addObject:firstNavController]; | |
tabBarController.viewControllers = localControllersArray; | |
tabBarController.delegate = self; | |
self.tabBarController.selectedIndex = 0; | |
[self.view addSubview:tabBarController.view]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment