iOS 小记--app周期

关于appdelegate的几个方法

active 活跃,就是当前app在前台被使用(eg:使用微信聊天时,微信就是active)

inactive 不活跃,悬挂 按home键quits app,这个app如果不支持background就是悬挂

backgroud 后台模式 支持backgroud mode的应用在使用被允许功能时候的状态,(eg:qq音乐在后台听歌,当前app是微信)

Terminate 中止,挂掉 我的理解是你双击home键,划掉它的动作。

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

当app将要从活跃状态跳入不活跃状态时被发送,这种情形出现在某一种被打断的情形(例如电话和短信进来的时候)或者用户quits app(这个动作不知道怎么翻译,单词quits是adj. 对等的;两相抵消的,quit是退出,quits app在有道被翻译成退出应用程序,而实际上ios的系统上app并没有退出应用程序的概念,这个quits app的动作我的理解是按下home键,或者挑战到别的app,anyway,就是一个让当前app不再前台的action)使它过渡到后台的时候。

实现这个方法去暂停连续任务,中止定时器,限制openGLES的rates(频率,渲染是耗内存耗cpu/gpu,好时间的活,当ap不再前台活跃的时候,这类活动就不要再浪费资源了)(停止UI)。游戏类app应该在这里暂停游戏。

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

实现这个方法去释放共享资源,保存用户数据,中止定时器,存储足够的app状态信息用来恢复你的app现在的状态因为它马上会被中止。

如果你的app支持后台运行模式,在用户quits app的时候这个方法将代替applicationWillTerminate:被调用。

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

在app从后台模式过渡到悬挂状态时被调用。这里你可以取消那些进入后台时的操作。

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

重新开始在app悬挂时被暂停的任务,如果你的app之前在后台活动(就是支持backGround模式),现在你该刷新你的UI界面了。

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

app将要Terminate,中止(我的理解是app走到了尽头,也就是当你双击home键把它划掉的时候);去保存你的数据,

你可能感兴趣的:(iOS 小记--app周期)