app 生命周期
2016-01-05 00:00
92 查看
@implementation AppDelegate
// Home 按键 : shitf+command +h
// application
// 应用程序加载完会跑这个方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// UIWindow : 窗口类;
// 在加载应用程序完成后,创建windows 对象
// 一个应用程序至少要有一个窗口对象;(95% 的应用程序都只有一个窗口对象)
// CGRect frme = CGRectMake(0, 0, 33, 33);
// 创建一个窗口对象,并把尺寸设置屏幕大小
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
// UIscreen 是个单例,使用类方法获取屏幕对象,可以通过该屏幕获取当前对象屏幕大小;
// struct CGRect {
// CGPoint origin;
// CGSize size;
// };
// struct CGPoint {
// CGFloat x;
// CGFloat y;
// };
// struct CGSize {
// CGFloat width;
// CGFloat height;
// };
CGRect rect = [UIScreen mainScreen].bounds;
//[UIScreen mainScreen];
// 设置背景颜色;
self.window.backgroundColor = [UIColor redColor];
// 让窗口的并显示出来;
self.window.rootViewController = [[UIViewController alloc]init];
[self.window makeKeyAndVisible];
NSLog(@"%@",NSStringFromCGRect(rect));
NSLog(@"download over..");
// 程序入口;
return YES;
}
// 应用程序将要进入后台时候调用
- (void)applicationWillResignActive:(UIApplication *)application {
// 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.
// 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.
// 这个方法里面可以释放共有的资源,保存数据,停止计时器等等操作;
NSLog(@"即将进入后台调用....");
}
// 应用程序进入后台时调用
- (void)applicationDidEnterBackground:(UIApplication *)application {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"已经进入后台");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// 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.
NSLog(@"应用程序将要进入前台....");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// 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.
// 重新启动应用程序
NSLog(@"应用程序已经进入前台");
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"应用程序终止...");
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
// 释放内存的操作;
NSLog(@"内存不足就调用该方法");
}
// Home 按键 : shitf+command +h
// application
// 应用程序加载完会跑这个方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// UIWindow : 窗口类;
// 在加载应用程序完成后,创建windows 对象
// 一个应用程序至少要有一个窗口对象;(95% 的应用程序都只有一个窗口对象)
// CGRect frme = CGRectMake(0, 0, 33, 33);
// 创建一个窗口对象,并把尺寸设置屏幕大小
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
// UIscreen 是个单例,使用类方法获取屏幕对象,可以通过该屏幕获取当前对象屏幕大小;
// struct CGRect {
// CGPoint origin;
// CGSize size;
// };
// struct CGPoint {
// CGFloat x;
// CGFloat y;
// };
// struct CGSize {
// CGFloat width;
// CGFloat height;
// };
CGRect rect = [UIScreen mainScreen].bounds;
//[UIScreen mainScreen];
// 设置背景颜色;
self.window.backgroundColor = [UIColor redColor];
// 让窗口的并显示出来;
self.window.rootViewController = [[UIViewController alloc]init];
[self.window makeKeyAndVisible];
NSLog(@"%@",NSStringFromCGRect(rect));
NSLog(@"download over..");
// 程序入口;
return YES;
}
// 应用程序将要进入后台时候调用
- (void)applicationWillResignActive:(UIApplication *)application {
// 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.
// 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.
// 这个方法里面可以释放共有的资源,保存数据,停止计时器等等操作;
NSLog(@"即将进入后台调用....");
}
// 应用程序进入后台时调用
- (void)applicationDidEnterBackground:(UIApplication *)application {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"已经进入后台");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// 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.
NSLog(@"应用程序将要进入前台....");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// 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.
// 重新启动应用程序
NSLog(@"应用程序已经进入前台");
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"应用程序终止...");
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
// 释放内存的操作;
NSLog(@"内存不足就调用该方法");
}
相关文章推荐
- Servlet3.1应用生命周期事件 (转载)
- 个人信息安全报告发布:有 APP 每分钟调用位置权限 1468 次
- 下载量超过一亿的流行应用被发现含有恶意模块
- 苹果与Siri的七年之痒:“宫斗”戏码不断上演
- APP添加CNZZ统计插件教程 Android版添加phonegap
- Android APP与媒体存储服务的交互
- java实现收藏名言语句台词的app
- 修改Android App样式风格的方法
- android横竖屏切换时候Activity的生命周期
- android生命周期深入分析(一)
- IIS处理Asp.net请求和Asp.net页面生命周期说明
- ASP.NET Web页生命周期和执行的方法介绍
- Android App数据格式Json解析方法和常见问题
- 通过Html网页调用本地安卓(android)app程序代码
- js判断移动端是否安装某款app的多种方法
- PHP实现批量生成App各种尺寸Logo
- Could not load file or assembly "App_Licenses.dll"的问题
- 关于PHP5 Session生命周期介绍
- Android桌面组件App Widget用法入门教程