zoukankan      html  css  js  c++  java
  • 应用程序代理AppDelegate解析

    应用程序UIApplication是通过代理和外部交互的,当应用程序生命周期中发生改变时UIApplication就会调用代理对应的方法。

    @implementation AppDelegate
    
    
    - (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 {
        //程序进入后台后执行,注意进入后台时会先失去焦点再进入后台;
        //分两种情况讨论:
        //1,当你的应用程序不支持后台运行的时候,该函数的作用等同于applicationWillTerminate:,关闭应用程序之前调用,保存上下文环境,释放资源等。
        //2,当应用程序支持后台运行时,该函数的作用是释放无用资源,保存上下文环境,以备应用程序由后台转入前台之后有足够的信息恢复到之前转入后台之前到状态。
        // 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:.
    }
    
    @end
  • 相关阅读:
    符号修饰与函数签名、extern “C”
    WinInet单线程断点续传下载
    关掉"离开模式“,解决计算机无法进入睡眠状态
    链接库——动态链接库
    Google开源项目风格指南——类
    使用CURL读取HTTP数据到字符串或者文件中
    Wininet多线程断点续传下载
    contains
    [转]在linux下如何使用Makefile对fortran程序进行编译
    【转】一些解决变态数学公式的算法地址
  • 原文地址:https://www.cnblogs.com/lxd2502/p/5105775.html
Copyright © 2011-2022 走看看