Tony
Tony

Reputation: 135

NavigationController not loading view

I'm using xCode 4.3.2 and started a blank application.

I have a navigation controller and a simple logincontroller. I want the login controller to be my root view so it is this first thing that a user does when they login.

I'm using the following code and when I run the application it displays a black screen. I put in logging in the LoginViewController.m->ViewDidLoad and it is being run is there something im doing wrong the LoginViewController.xib is very simple it just contains a button right now that will switch to a tab view controller once I figure this out.

Thanks in advance.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:     (NSDictionary *)launchOptions
    {
        UIViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
        navigationController = [[UINavigationController alloc] initWithRootViewController:loginController];



        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        [self.window addSubview:navigationController.view];
        [self.window makeKeyWindow];


        return YES;
    }

Upvotes: 0

Views: 682

Answers (1)

David Hoerl
David Hoerl

Reputation: 41622

This is not right:

[self.window addSubview:navigationController.view];

change it to this:

self.window.rootViewController = navigationController;

Upvotes: 1

Related Questions