1 #import "AppDelegate.h"
2
3 @interface AppDelegate ()
4
5
6 @end
7
8 @implementation AppDelegate
9
10 // 加载info.plist,并且做判断,判断完没有main,就不会帮你创建窗口,自己手动创建
11 // 程序启动完成的时候调用
12 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
13
14 // 窗口显示注意点:1.不要让窗口销毁,需要弄一个强引用 2.必须要设置窗口的尺寸
15 // 1.创建窗口的对象
16 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
17
18 self.window.backgroundColor = [UIColor redColor];
19
20
21 // 2.创建窗口的跟控制器,并且赋值
22 // 苹果推荐使用控制器的原因,对应界面的事情交给对应的控制器去管理
23 UIViewController *rootVc = [[UIViewController alloc] init];
24
25 rootVc.view.backgroundColor = [UIColor greenColor];
26
27 // 一旦设置窗口的根控制器,就会把根控制器的view添加到窗口
28 // 做了旋转功能
29 self.window.rootViewController = rootVc;
30
31 // UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
32 // btn.center = CGPointMake(50, 50);
33 // [rootVc.view addSubview:btn];
34 // [self.window addSubview:rootVc.view];
35
36 // 3.显示窗口
37 // 1.可以显示窗口 self.window.hidden = NO;
38 // 2.成为应用程序的主窗口 application.keyWindow = self.window;
39
40 [self.window makeKeyAndVisible];
41
42
43 //
44 // NSLog(@"%@",self.window);
45
46 return YES;
47 }
48
49 - (void)applicationWillResignActive:(UIApplication *)application {
50 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
51 // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
52 }
53
54 - (void)applicationDidEnterBackground:(UIApplication *)application {
55 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
56 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
57 }
58
59 - (void)applicationWillEnterForeground:(UIApplication *)application {
60 // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
61 }
62
63 - (void)applicationDidBecomeActive:(UIApplication *)application {
64 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
65 }
66
67 - (void)applicationWillTerminate:(UIApplication *)application {
68 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
69 }
70
71 @end