Wednesday, August 22, 2012

Adding UINavigation to a Simple View iOS Application Programmatically in Xcode

Since there release of new Xcode, there is no option for creating navigation based application. This simple post will show you how to do it programmatically.

Firstly, create a new project in Xcode selecting simple view application templete. Then in your AppDelegate.h file create a UINavigationController  object

 @property (strongnonatomicUINavigationController* navigationController;

Then in the AppDelegate.m file modify the method

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow allocinitWithFrame:[[UIScreen mainScreenbounds]];
    navigationController =[[UINavigationController allocinit];

    self.viewController = [[ViewController allocinitWithNibName:@"ViewController" bundle:nil];

    [navigationController pushViewController:self.viewController animated:NO];
    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];
    return YES;

Then you are good to go :)

No comments:

Post a Comment