iOS应用程序的生命周期

//——————————————————————————整个应用的入口函数

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

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.

//应用程序从活跃状态切换到不活跃状态这个函数将会被调用(消息),这也会在某些临时状态发生,(比如来了电话。SMS短信这个函数也会被调用)或者当用户退出了应用程序,他开始切换到后台模式

// 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.

//我们应该做什么???用这个方法我们要暂停正常的任务,关闭定时器,降低opengless的游戏频率,暂停游戏

}

//——————————————————————————已经进入到后台

- (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.

}

//——————————————————————即将切换到前台的回调函数

- (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.

//如果从背景模式切换到不活跃状态,这个函数会被调用

//在这里可以做一些和之前进入后台相反的操作,恢复之前进入后台保存的内容

}

//————————————————————————程序已经切换到前台

- (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.

//重新启动被暂停的业务,如果如果应用程序在后台,那么这里要刷新UI(User Interface)

}

//

- (void)applicationWillTerminate:(UIApplication *)application

{

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

//当应用程序停止回调函数,这个只有在<ios4.0调用  活着大于 iOS>4.0

//设置了 不能后台模式调用

}

时间: 2024-08-11 03:27:02

iOS应用程序的生命周期的相关文章

[转载] iOS应用程序的生命周期

iOS应用程序的生命周期 2015-06-23 iOS大全 (点击上方蓝字,快速关注我们) iOS应用程序一般都是由自己编写的代码和系统框架(system frameworks)组成,系统框架提供一些基本infrastructure给所有app来运行,而你提供自己编写的代码来定制app的外观和行为.因此,了解iOS infrastructure和它们如何工作对编写app是很有帮助的. Main函数入口 所有基于C编写的app的入口都是main函数,但iOS应用程序有点不同.不同就是你不需要为iO

iOS 应用程序的生命周期详解

今天看了一下午的iOS 应用程序的生命周期,本来对这些只是大概的了解,并没有深入的去了解他,,所以也没有太在意,今天突然觉得做iOS 开发  一定要明白应用程序在整个手机系统的前台后台的运行状态.应用程序各个状态的变换,及调用的哪些方法,结合着一些资料,也开始写出我对这个的理解 iOS系统的资源是有限的,应用程序在前台和在后台的状态是不一样的.在后台时,程序会受到系统的很多限制,这样可以提高电池的使用和用户体验. //开发iOS app,我们要遵循苹果公司的一些指导原则,原则如下: 1.应用程序

iOS 应用程序的生命周期(转CocoaChina)

对于iOS应用程序,关键是要知道你的应用程序是否正在前台或后台运行.由于系统资源在iOS设备上较为有限,一个应用程序必须在后台与前台有不同的行为.操作系统也会限制你的应用程序在后台的运行,以提高电池寿命,并提高用户与前台应用程序的体验.当应用程序在前台和后台之间切换时,操作系统将会通知您的应用程序.你可以通过这些通知来修改你的应用程序的行为. 当你的应用程序在前台活动时,系统会发送触摸事件给它进行处理.在UIKit的基础设施做了大部分的事件传递给你的自定义对象工作.所有您需要做的是覆盖在相应的对

iOS 应用程序的生命周期浅析

做ipone开发有必要知道iPhone程序的生命周期,说白了就是点击应用图标启动程序到到退出程序,在这个运行的过程中底下的代码到底发生了什么,只有理解生命周期,有利于我们开发人员开发出更好的应用. 当用户点击一个图片的时候,程序开始运行,从main函数开始: int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDe

[转]iOS 应用程序的生命周期

OS的应用程序的生命周期,还有程序是运行在前台还是后台,应用程序各个状态的变换,这些对于开发者来说都是很重要的. iOS系统的资源是有限的,应用程序在前台和在后台的状态是不一样的.在后台时,程序会受到系统的很多限制,这样可以提高电池的使用和用户体验. //开发app,我们要遵循apple公司的一些指导原则,原则如下: 1.应用程序的状态 状态如下: Not running  未运行  程序没启动 Inactive          未激活        程序在前台运行,不过没有接收到事件.在没有

iOS开发-程序的生命周期

为了更好的管理程序,了解程序的生命周期是很有必要的. 运行结果: 1.首次启动: 2015-05-26 17:33:28.362 Live[4858:214241] 程序开始 2015-05-26 17:33:28.627 Live[4858:214241] 程序再次激活 2.按HOME键退出: 2015-05-26 17:35:33.335 Live[4858:214241] 程序暂停 2015-05-26 17:35:33.970 Live[4858:214241] 程序进入后台 3.再次进

iOS-深度解析iOS应用程序的生命周期

摘要:iOS应用程序一般都是由自己编写的代码和系统框架组成,系统框架提供一些基本infrastructure给App来运行,而开发者则自己编写代码定制App的外观和行为,了解iOS Infrastructure及其如何工作对编写App很有帮助. iOS应用程序一般都是由自己编写的代码和系统框架(system frameworks)组成,系统框架提供一些基本infrastructure给所有App来运行,而你提供自己编写的代码来定制App的外观和行为. 因此,了解iOS Infrastructur

iOS学习笔记—ViewController/生命周期

ViewController是iOS应用程序中重要的部分,是应用程序数据和视图之间的重要桥梁,ViewController管理应用中的众多视图.iOS的SDK中提供很多原生ViewController,以支持标准的用户界面,例如表视图控制器(UITableViewController).导航控制器(UINavigationController).标签栏控制器(UITabbarController)和iPad专有的UISplitViewController等. 按结构可以对iOS的所有ViewCo

iOS学习笔记-ViewController/生命周期

ViewController是iOS应用程序中重要的部分,是应用程序数据和视图之间的重要桥梁,ViewController管理应用中的众多视图.iOS的SDK中提供很多原生ViewController,以支持标准的用户界面,例如表视图控制器(UITableViewController).导航控制器(UINavigationController).标签栏控制器(UITabbarController)和iPad专有的UISplitViewController等. 按结构可以对iOS的所有ViewCo