2010-03-30 126 views

回答

2

將這個代碼

在委託的.h類

 MyViewController *viewController; 

在委託.M類

- (void)applicationDidFinishLaunching:(UIApplication *)application {  

UINavigationController *nvcontrol =[[UINavigationController alloc] initWithRootViewController:viewController]; 

[window addSubview:nvcontrol.view]; 

[window makeKeyAndVisible]; 

} 

這裏「MyViewController」應該被你的viewcontroller替換。

全部最好。

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; 
} 
相關問題