Steps:
- List item
- Create a project called Nav.
- Create a new
UIViewController
BaseViewController (with XIB) and FirstViewController (with XIB). In the
NavAppDelegat.h
define baseController variable@interface NavAppDelegate : NSObject <UIApplicationDelegate> { BaseViewController *baseController; } @property (nonatomic, retain) IBOutlet BaseViewController *baseController;
In the
NavAppDelegat.m
add baseController to the window:@synthesize baseController; (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self.window addSubview:baseController.view]; [self.window makeKeyAndVisible]; return YES; }
Open the BaseViewController.xib file and add
UINavigationController
, set its Root View Controller class and XIB to FirstViewController (in the inspector).- Also connect navigationController variable with the
UINavigationController
.
I believe this should show me the FirstViewController with the navigation bar. If I do this directly on the MainWindow.xib things are working as I expected but here I can't see the navigation bar. What am I missing? THx!
UPDATE:
So the problem is only that in case I use UINavigationController
inside some additional controller (BaseViewController.xib here) instead of MainWindow.xib i don't see the navigation bar.