iOS_study_fourth

来源:互联网 发布:司马懿之军事联盟 知乎 编辑:程序博客网 时间:2024/06/03 15:05
UIapplication 生命周期://即将进入后台- (void)applicationWillResignActive:(UIApplication *)application{    NSLog(@"function %d is calling",NSStringFromSelector(_cmd));    //_cmd:表示当前函数    //应用程序即将从活跃状态切换到不活跃状态,这也会在某些临时状态发生(比如来了电话或者是短信)或者当用户退出了应用程序    //它将切换到后台状态。我们应该做什么?用这个方法我们做暂停正常运行的任务,关闭定时器,降低openGl的游戏贞率,暂停游戏    // 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{    NSLog(@"function %d is calling",NSStringFromSelector(_cmd));    // 用这个方法来释放共享资源,保存用户数据,作废定时器,保存足够多的用户状态信息以便程序终止,我们下次还能恢复之前的状态信息    // 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.    //如果你的程序支持后台的花,这个函数会被调用  applicationWillTerminate:不会被调用    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.}//即将切换到前台的回调函数- (void)applicationWillEnterForeground:(UIApplication *)application{    NSLog(@"function %d is calling",NSStringFromSelector(_cmd));    //如果从背景模式切换到不活跃状态,这个函数会被调用。    // 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.}//已经切换前台/active模式- (void)applicationDidBecomeActive:(UIApplication *)application{    NSLog(@"function %d is calling",NSStringFromSelector(_cmd));    //重新启动暂停的任务,如果应用程序在后台,那么这里要刷新ui(ui interface)    // 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.}//当应用程序终止的时候调用,这个函数只有在<iOS4.0 ,或者在>iOS 4.0 设置了不能后台模式调用- (void)applicationWillTerminate:(UIApplication *)application{    NSLog(@"function is calling",NSStringFromSelector(_cmd));    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.}-(void) applicationDidReceiveMemoryWarning:(UIApplication *)application{    //应用程序内存警告     NSLog(@"function is calling",NSStringFromSelector(_cmd));}

0 0
原创粉丝点击