步骤:
更新: 所以问题只是当我在其他控制器(这里是BaseViewController.xib)中使用UINavigationController而不是MainWindow.xib时,我看不到导航栏。
- 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
.
更新: 所以问题只是当我在其他控制器(这里是BaseViewController.xib)中使用UINavigationController而不是MainWindow.xib时,我看不到导航栏。