Search code examples
iphoneuiviewcontrolleruinavigationcontroller

how to load UINavigationController from Uiviewcontroller


I want to load my UINavController from my UIViewController. My interface details is here.

@interface ContactUs : UIViewController {

    IBOutlet UIWindow *window;

    IBOutlet UINavigationController *navController;

}

@property (nonatomic,retain) IBOutlet UINavigationController *navController;

@end

and in implementation ..

@synthesize window;

@synthesize navController;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

 -(void)viewDidLoad {

  [window addSubview:navController.view];

  [window makeKeyAndVisible];

    [super viewDidLoad];
    

        NSLog(@":::::::::::::::::::");

}
 

But unfortunate my UINavigationController is not loading. I am seeing a blank windows is appearing.


Solution

  • @interface ContactUs : UINavigationViewController {
    
          IBOutlet UIWindow *window;
    
          IBOutlet UITextView *textView;
          IBOutlet UIButton *button;
    
           }
    
       // Add properties to the all outlets //
    
         -(IBAction) buttonpressed: (id) sender;
    

    And in the implementation - write the code for buttonpressed and you can make use that for whatever your goals are.