ios app生命周期学习笔记(一)
来源:互联网 发布:配置ubuntu镜像站 编辑:程序博客网 时间:2024/05/16 04:18
参考文档:https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html#//apple_ref/doc/uid/TP40007072-CH2-SW1
1.入口函数是The Main Function,主要功能包括,加载storyboard中的user interface;调用初始化方法
2.app的结构如下
Key objects in an iOS app
The Main Run Loop
Processing events in the main run loop
Execution States for Apps
Not running: app没有加载或者是正在运行时被系统终止了。
Inactive: app进入到前台了但是还没有接收到事件通知。但是也能执行一些代码操作。
Active: app进入前台并且接收事件通知。这个进入前台app的常见模式。
Background: app进入后台并且执行代码。大部分的app进入到后台后会很快被挂起,但是有需要执行代码的话在这个阶段也可以停留一段时间。
Suspended: 挂起。app进入后台并且没有执行代码。系统会自动将app置入这个状态并且不会通知app。当挂起的时候,app在内存中但是不会再执行任何的代码操作。
application:willFinishLaunchingWithOptions:—This method is your app’s first chance to execute code at launch time.
application:didFinishLaunchingWithOptions:—This method allows you to perform any final initialization before your app is displayed to the user.
applicationDidBecomeActive:—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation.
applicationWillResignActive:—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state.
applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time.
applicationWillEnterForeground:—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active.
applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//程序第一次启动就执行一次的地方
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.
}
- (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.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
[self saveContext];
//app 被kill掉时会调用此方法
}
- ios app生命周期学习笔记(一)
- iOS学习笔记《一》app icon
- ios学习(一):应用生命周期
- iOS开发学习笔记 -- (一)hybrid app
- Swift开发iOS App学习笔记(一)---AppIcon & LaunchScreen
- IOS学习笔记1(入门)——UI继承关系(转)、App生命周期
- 详解iOS App生命周期
- iOS: App的生命周期
- 详解iOS App生命周期
- iOS App 生命周期
- iOS App生命周期
- iOS App的生命周期
- iOS App的生命周期
- iOS App的生命周期
- iso学习笔记(2)ios生命周期
- IOS 学习笔记16 UIViewControl生命周期
- IOS学习笔记——ViewController生命周期
- IOS学习笔记 ——生命周期
- JDK1.7新特性--自动关闭类
- MyBatis-动态SQL的if、choose、when、otherwise、trim、where、set、foreach使用
- ios简单动画全解
- webView常见漏洞以及解决方法
- 开个博客
- ios app生命周期学习笔记(一)
- 一起做RGB-D SLAM (3) 特征提取与配准
- hdu 1560 DNA sequence(IDA*)
- Python HTTP库requests中文页面乱码解决方案!
- docker dockerfile 部署java web
- NSAssert和NSParameterAssert
- MSP430G2553 定时器中断实例
- 关于jsp中usebean中class=?问题
- mysql复习小结二事务的实验总结