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的职责主要包括管理内 ...
随机推荐
- HTTP基本认证(Basic Authentication)的JAVA实例代码
大家在登录网站的时候,大部分时候是通过一个表单提交登录信息. 但是有时候浏览器会弹出一个登录验证的对话框,如下图,这就是使用HTTP基本认证. 下面来看看一看这个认证的工作过程: 第一步: 客户端发送 ...
- shell程序练习
#!/bin/sh通知采用bash解释.如果在echo语句中执行shell命令date,则需要在date命令前面加符号&: 编辑完文件之后不能立即执行该文件,需要给文件设置可执行权限.chmo ...
- php中while($row = $results->fetch_row())调用出错
php中while($row = $results->fetch_row())调用出错 错误处在sql语句上
- 远程访问Mysql的解决方案
在网上有很多关于这个的解决方案,我也采用了 写的比较详细的如:1. 改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更 ...
- ffmpeg 和 x264的参数对照
ffmpeg 和 x264的参数对照 x264 ffmpeg 说明 命令行 字段 命令行 字段 qp qp_constant cqp cqp 固定量化因子.取值范围0到51. 经常取值在20-40 ...
- 【转载】【Pycharm编辑器破解步骤】之idea和Pycharm 等系列产品激活激活方法和激活码(附:Mac系统)
感谢:雪中皓月的<idea和Pycharm 等系列产品激活激活方法和激活码> 第一种方法:使用现有的注册服务器 优点:快捷,方便,省事 缺点:经常被封杀,可能会面临经常激活的困扰 Lice ...
- 禁用LinkButton的方法
1.服务器端,使用Enabled属性即可 <asp:LinkButton ID="lbtn" runat="server" Enabled="f ...
- 【 D3.js 入门系列 --- 9.4 】 集群图的制作
本人的个人博客为: www.ourd3js.com csdn博客为: blog.csdn.net/lzhlzz 转载请注明出处,谢谢. 集群图( Cluster )通经常使用于表示包括与被包括关系. ...
- [转]使用TeamCity对项目进行可持续集成管理(一)
一.可持续集成管理 持续集成,CI:即Continuous integration. 可持续集成的概念是基于团队(小组)协作开发而提出来的,为了提高团队开发效率与降低集成风险(早发现,早解决.晚发现, ...
- 4190. Prime Palindromes 一亿以内的质数回文数
Description The number 151 is a prime palindrome because it is both a prime number and a palindrome ...