简体   繁体   中英

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. Thanks in advacnce

If you want to use the Navigation View controller over the View controller.. Why not use the UINavigationController?

        @interface ContactUs : UINavigationViewController {

          IBOutlet UIWindow *window;

          // IBOutlet UINavigationController *navController; // You do not need this. 

         }
@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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM