标签:
- (void)loadView
{
self.view = [[UIView alloc]init];
self.view.backgroundColor = [UIColor redColor];
}
加载storyboard的方法:
1>在project--targets--MainInterface指定storyboard
2>代码加载
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
UIStoryboard *myStoryboard = [UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil];
self.window.rootViewController = [myStoryboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[QKViewController alloc]initWithNibName:@"myViewController" bundle:nil];
[self.window makeKeyAndVisible];
return YES;
}
前面5步的流程图:
当程序内存不够用时,最先拿到内存警告的是UIApplication→Window→Window.rootViewController→.....(一层一层往下传).
控制器收到内存警告时,如果要确定要销毁View,则会调用viewWillUnload\viewDidUnload.
控制器是这样判断View是否需要销毁的:
标签:
原文地址:http://www.cnblogs.com/oumygade/p/4295042.html