Showing posts with label UINavigationController. Show all posts
Showing posts with label UINavigationController. Show all posts

Tuesday, November 15, 2011

UINavigationController Customization Tutorial


Creating a UINavigationController programmatically

Creating a UINavigationController programmatically is trivial. Assuming that you’ve already created a class called RootViewController that subclasses UIViewController, you would use something like this, typically in your AppDelegate file:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// rootViewController can't be an instance of UITabBarController
// remember to include RootViewController in your class!
RootViewController * rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];

[self.window addSubview:navigationController.view];

// Don't bother releasing navigationController as it needs to be around all the time

   [self.window makeKeyAndVisible];

   return YES;
}