barfoon
barfoon

Reputation: 28157

Building a Navigation-Based project starting from a Window based project

Just trying to wrap my head around how different project types are built and I must be missing something.

I'm trying to start with a window based application and just add a Navigation Controller so I understand how the different components work with the Window and App delegate.

Here's what I did:

In my app delegate.m I added:

@synthesize navigationController;

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

Builds clean, when I launch I get an all white screen.

What am I missing?

Upvotes: 1

Views: 226

Answers (3)

barfoon
barfoon

Reputation: 28157

Figured it out - I had to create a new Referencing outlet and connect the Navigation Controller to the App Delegate in the .xib.

Upvotes: 1

Sudesh Kumar
Sudesh Kumar

Reputation: 569

Actually barfoon..your navigation controller does not contains any UIViewController. First of all create new UIViewController and than add it to UINavigationController. UINavigationController is just like stack ,which handle each and every added UIViewController i.e traversing like back and forth. Ex..

ToDoController *toDoObj = [[ToDoController alloc] initWithNibName:@"ToDoController" bundle:[NSBundle mainBundle]];
UINavigationController *toDoNav = [[UINavigationController alloc] initWithRootViewController:toDoObj];
[self.window addSubview:toDoNav.view];

Upvotes: 1

visakh7
visakh7

Reputation: 26400

Add this [self.window addSubview:self.navigationController.view]; You need to add the navigation controllers view to the window. Also make sure that the outlet for the navigation controller is connected. You will also need to add root view controller for the navigation controller

Upvotes: 1

Related Questions