Skip to content

Instantly share code, notes, and snippets.

@seansullivan
Created August 3, 2012 05:50
Show Gist options
  • Save seansullivan/3244870 to your computer and use it in GitHub Desktop.
Save seansullivan/3244870 to your computer and use it in GitHub Desktop.
Set up navigation inside view controller
// 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