views:

92

answers:

3

I have created a window-based application and my problem is I am unable to create UINavigationController on the go. InFact I don't know how to do that.

My AppDelegeate

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch
    [window addSubview:logInView.view];
    [window makeKeyAndVisible];
}

here the logInView is an object of

@interface LogInViewController : UIViewController {
    IBOutlet UITextField *usernameField;
    IBOutlet UITextField *passwordField;
    IBOutlet UIButton *logInButton;
}

-(IBAction) logInClick:(id) sender;

from the click action of this loginviewcontroller It should be showing the home screen with navigation controller. and I have to add many subviews. My question is where should I init the UINavigationController and where could I write the codes for adding subviews? how to map it with interfacebuilder?

A: 

I would start with a UINavigationController (where LoginViewController is the root view controller), and set

self.navigationController.navigationBarHidden = YES;

in LoginViewController.

Can Berk Güder
A: 

Have you started with the View Controller Programming Guide's discussion of Navigation Controllers? It includes code samples for this, along with extensive discussion.

You should also create an empty project with the Navigation Controller template and explore how the template is set up. You may find it easier to start with the NavController template, and add your login screen to that rather than starting with the Window template and trying to add a NavController. But studying NavController is a good learning experience in any case.

Rob Napier
A: 

Hi, First you have to add navigation controller in your program.

Try this code,

 - (void)applicationDidFinishLaunching:(UIApplication *)application {    

 UINavigationController *nvc =[[UINavigationController alloc] initWithRootViewController:logInView];

   [window addSubview:nvc.view];

    [window makeKeyAndVisible];

}

Best of Luck.

Pugal Devan