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的职责主要包括管理内 ...
随机推荐
- yum安装方式的php,切换NTS为ZTS版本
用 yum安装方式的php,切换NTS为ZTS版本(切换为线程安全版本) 最好按我这个方法安装(安装比较全一点): https://www.cnblogs.com/fps2tao/p/7699448. ...
- 点滴积累【JS】---JQuery实现条形统计图,适用于选择题等统计
效果: 思路:前台JS实现动态数据效果,后台可以拼接字符串或者用JSON加载数据 代码: <%@ Page Language="C#" AutoEventWireup=&qu ...
- NGUI拖拽简介
挂上UIDragDropItem就可以实现拖拽,按钮监听Drop消息即可实现对拖放的监听. UIDragDropItem有一个Clone On Drag选项,勾上可以克隆,但会被ScrollView遮 ...
- 【flink training】 打车热点区域实时统计PopularPlaces
http://training.data-artisans.com/是Apache Flink商业公司DataArtisans提供的一个flink学习平台,主要提供了一些业务场景和flink api结 ...
- hdoj 1288 Hat's Tea
Hat's Tea Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- ajax发送请求时为url添加参数(使用函数)
<script> // ajax的get请求,使用函数向其url添加参数 function addURLParam(url,name,value){ url+=(url.indexOf(' ...
- 本地测试Tomcat配置Https访问
一.tomcat开启HTTPS配置 1) 准备证书 使用jdk工具keytool生成一个ssl测试用证书, 一路按照提示操作输入即可 keytool -genkey -alias tomcat -ke ...
- mysql数据库表修改某一列的类型
下面列出:1.增加一个字段alter table user add COLUMN new1 VARCHAR(20) DEFAULT NULL; //增加一个字段,默认为空alter table use ...
- Angular js ie 7,8 兼容性
Angularjs 官网有云: 1)在html 里面 ,有ng-app 的标签里需要定义个id ,id='ng-app'; 2)ie 7及以下版本需要json2.js或json3.js,主要用来解析 ...
- db_keep_cache_size參数的控制范围測试
ocm考试新题中.须要创建keep存储的表,但在该參数是否应该改动上,有一些分歧.有人说asmm会自己主动给keep分配内存的,该參数就不用设置了. 看文档和asktom.也是云山雾罩,说什么的都有, ...