我应该如何创建一个在基于视图的应用程序中使用的NavigationController?
答案 0 :(得分:2)
把这段代码
代表.h班
MyViewController *viewController;
在委托.m班
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UINavigationController *nvcontrol =[[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:nvcontrol.view];
[window makeKeyAndVisible];
}
此处“MyViewController”应由viewcontroller替换。
所有最好的。
答案 1 :(得分:1)
答案 2 :(得分:1)
在delegate.h中
@class test24ViewController;
@interface test24AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
test24ViewController *viewController;
UINavigationController *nav;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet test24ViewController *viewController;
@property (nonatomic, retain) IBOutlet UINavigationController *nav;
在delegate.m
@synthesize nav;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
nav=[[UINavigationController alloc]init];
[nav pushViewController:viewController animated:YES];
// Override point for customization after application launch.
[self.window addSubview:nav.view];
[self.window makeKeyAndVisible];
return YES;
}