iOS应用程序的生命周期

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
   //设置了 不能后台模式调用
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

静守晨昏‍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值