//
// SwitchViewControllerAppDelegate.h
#import
@class SwitchViewController;
@interface SwitchViewControllerAppDelegate : NSObject
UIWindow *window;
SwitchViewController *_switchViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet SwitchViewController *_switchViewController;
@end
剛剛輸入的IBOutlet宣告目的是在 應用程式啓動時 將root controller(_switchViewController)的view加入到應用程式的主視窗, 所以必須建立IBOutlet
//
// SwitchViewControllerAppDelegate.m
#import "SwitchViewControllerAppDelegate.h"
#import "SwitchViewController.h"
@implementation SwitchViewControllerAppDelegate
@synthesize window;
@synthesize _switchViewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self.window addSubview:_switchViewController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[window release];
[_switchViewController release];
[super dealloc];
}
@end
沒有留言:
張貼留言