美文网首页iOS UIApplication
ios开发笔记-关于UIApplication(下)代理 App

ios开发笔记-关于UIApplication(下)代理 App

作者: Topus | 来源:发表于2018-02-17 13:48 被阅读5次

    这个系列主要写一些平时ios开发和学习过程中所记录的问题、随笔和解决方法,我会尽量用更多的截图或者gif图来还原我的开发现场,在执行个人备忘录功能的同时希望对你有所帮助。

    1.背景

    移动操作系统的app容易受到来电或者锁屏等干扰,在app受到干扰时会产生一些系统事件,这时UIApplication会通知它的delegate对象,让代理来处理这些系统事件

    2.AppDelegate方法含义

    //1.应用程序启动完毕时调用

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        // Override point for customization after application launch.

        return YES;

    }

    //2.应用程序将要失去焦点时调用

    - (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 invalidate graphics rendering callbacks. Games should use this method to pause the game.

    }

    //3.应用程序进入后台时调用

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

    }

    //4.应用程序进入前台时调用

    - (void)applicationWillEnterForeground:(UIApplication *)application {

        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

    }

    //5.应用程序获取焦点

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

    }

    //6.应用程序退出时调用

    - (void)applicationWillTerminate:(UIApplication *)application {

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

    }

    注意:失去焦点的意思是不能与用户进行交互

    相关文章

      网友评论

        本文标题:ios开发笔记-关于UIApplication(下)代理 App

        本文链接:https://www.haomeiwen.com/subject/tcbmtftx.html