iOS程序的执行顺序

1 进入程序的入口

进入main函数,设置Appdelegate成为在主函数的代理

2 程序完成加载

-[appDelegate application:didFinishLaunchingWithOptions:]

3 创建window窗口

4程序被激活

-[APPDelegate applicationDidBecomeActive:]

5点击Home键程序取消激活状态

程序取消激活状态

- [AppDelegate applicationWillResignActive:]

程序进入后台

-[APPDelegate applicationDidEnterBackground]

6点击进去工程

程序进去前台

-[APPDelegate applicationWillEnterForeground:]

程序被激活

-[APPDelegate applicationDidbecomeActive:]


下面是每个方法的作用

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"程序取消激活状态");
    NSLog(@"%s", __FUNCTION__);
    // 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.使用这种方法暂停正在进行的任务,禁用计时器,和节流OpenGL ES帧率。游戏应该使用这种方法暂停游戏
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
        NSLog(@"程序进入后台");
        NSLog(@"%s", __FUNCTION__);
    // 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.如果您的应用程序支持后台执行,而不是调用此方法applicationWillTerminate:当用户退出。
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"程序进入前台");
        NSLog(@"%s", __FUNCTION__);
    // 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
{
        NSLog(@"程序被激活");
        NSLog(@"%s", __FUNCTION__);
    // 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
{
    NSLog(@"程序被终止");
        NSLog(@"%s", __FUNCTION__);
    // Called when the application is about to terminate. Save data if appropriate. 
See also applicationDidEnterBackground:.当应用程序即将终止。如果适当的保存数据。参见applicationDidEnterBackground:
}











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值