iOS开发——生命周期
为了处理好应用程序的挂起、暂停等情况下的数据保存,或对应添加所需处理,我们必须了解ios生命周期。
但是不要去背去记,做个实验就好。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSLog(@"程序开始");
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(@"程序意外终止");
}
实验结果:
1.首次启动应用程序:
2012-06-26 11:06:39.313 WQTest[485:17903] 程序开始
2012-06-26 11:06:39.320 WQTest[485:17903] 程序再次激活
2.摁HOME键退出:
2012-06-26 11:08:08.687 WQTest[485:17903] 程序暂停
2012-06-26 11:08:08.690 WQTest[485:17903] 程序进入后台
3.再次进入程序:
2012-06-26 11:09:11.047 WQTest[485:17903] 程序进入前台
2012-06-26 11:09:11.049 WQTest[485:17903] 程序再次激活
iOS开发——生命周期的更多相关文章
- 图解ios程序生命周期
图解ios程序生命周期 应用程序启动后状态有Active.Inactive.Background.Suspended.Not running这5种状态,几种状态的转换见下图: 在AppDelegate ...
- (转)深入浅出 iOS 之生命周期
原文:http://www.cocoachina.com/applenews/devnews/2011/0817/3129.html 深入浅出 iOS 之生命周期 发布于:2011-08-17 10: ...
- 【PMP】项目生命周期和开发生命周期
一.定义 项目生命周期:指项目从启动到完成所经历的一系列阶段. 开发生命周期:项目生命周期内通常有一个或多个阶段与产品.服务或成果的开发相关,这些阶段称为开发生命周期. 二.生命周期 预测型生命周期( ...
- 【应用安全】S-SDLC安全开发生命周期
0x01 S-SDLC简介 OWASP Secure Software Development Lifecycle Project(S-SDLC)是OWASP组织首个由OWASP中国团队独立发布并主导 ...
- 【应用安全】微软的安全开发生命周期(SDL)
0x01 SDL介绍 安全开发生命周期(SDL)即Security Development Lifecycle,是一个帮助开发人员构建更安全的软件和解决安全合规要求的同时降低开发成本的软件开发过程. ...
- 【转】深入浅出 iOS 之生命周期
[iOS]深入浅出 iOS 之生命周期 深入浅出 iOS 之生命周期 http://blog.csdn.net/kesalin/article/details/6691766 罗朝辉(http:// ...
- 【转】VS 安全开发生命周期(SDL)检查
前面在学习使用google的protobuf时在VS2012中一直无法编译编译通过,经过查找一些资料原来发现,并不是protobuf的问题,而是自己在使用VS2012时,没有完全了解VS2012的强大 ...
- 软件开发生命周期(SDLC)
一.简介 软件开发生命周期又叫做 SDLC(Software Development Life Cycle),它是集合了计划.开发.测试和部署过程的集合.如下图所示 : 二.五个阶段 1.分析阶段: ...
- 【Xamarin 开发 IOS --IOS ViewController生命周期】
ViewController ViewController是IOS开发中MVC模式中的C,ViewController是view的controller,ViewController的职责主要包括管理内 ...
随机推荐
- 检查SSD磁盘是否开启了TRIM指令
fsutil behavior QUERY DisableDeleteNotify 如果查询结果是“DisableDeleteNotify = 0”,代表SSD已经支持并启用Trim指令:如果提示为“ ...
- Build System 和Test Framework overview总结
良好的自动化系统可以帮助Dev/Tester快速发现product/test code issue. 正好上一个项目结束,上个项目在自动化系统上面做得非常好.从产品开始时半年release一次到后面每 ...
- [docker]docker日志驱动记录nginx日志情形探究
这里研究下容器nginx记录日志的集中情况,主要想弄明白,docker的日志--log-driver=fluentd 改成fluentd后,会不会在本地在记录一份日志 整体架构是这样的 情况1: 首先 ...
- 使用tar+lz4/pigz+ssh更快的数据传输
使用tar+lz4/pigz+ssh更快的数据传输 -- | :41分类:Linux,MySQL | 前面一篇介绍了如何最大限度的榨取SCP的传输速度,有了这个基础,就可以进一步的使用压缩来加速传输速 ...
- ORACLE / PLSQL 插入或更新数据的几种方式
第一种,直接用values 插入 ---日期需要用TO_DATE操作 INSERT INTO EMP (EMPNO,ENAME ,JOB,MGR, HIREDATE , SAL ,COMM, DEPT ...
- 跟着百度学PHP[14]-PDO之Mysql的事务处理1
事务处理:在实际案例当中干一件事的mysql语句(好比转账,小一同学转账100,小二同学收账,在mysql当中小一就要减去转账的钱,小二就要增加100快)倘若该语句执行过程中有任何一条的sql语句出错 ...
- 跟着百度学PHP[14]-PDO的预处理语句2
在$sql = $pdo -> prepare("insert into users(gold,user,password) values(?,?,?)"):条语句我们不仅仅 ...
- POJ 2472 106 miles to Chicago
最短路问题变形. 题意是给你一些道路,和路过时不被抓的概率. 要求找一条到达目的地时不被抓的最大概率概率. 初始 dis[]设为 1 .其余为 0 .找最大就可以. #include<cstdi ...
- The Definitive Guide To Django 2 学习笔记(五) 第四章 模板 (一)基本模板系统
引入模板系统的原因,view中引入硬编码并非明智的选择,设计上的任何改变都会需要改动代码.python代码和HTML代码应该分开,这是多数Web站点的共识,分开会提高效率. 基本模板系统 Django ...
- org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in ……
编程中遇到:org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot ...