美文网首页
iOS APP状态说明

iOS APP状态说明

作者: iOS_tree | 来源:发表于2019-07-31 14:43 被阅读0次

我们创建一个iOS新项目的时候,系统会默认创建一个AppDelegate类,并实现UIApplicationDelegate协议的相关方法,代码如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    DLog(@"%@",self);
    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 invalidate graphics rendering callbacks. Games should use this method to pause the game.
    DLog(@"%@",self);
}


- (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.
    DLog(@"%@",self);
}


- (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.
    DLog(@"%@",self);
}


- (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.
    DLog(@"%@",self);
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    DLog(@"%@",self);
}

当我们在app进入前台后台需要做相关操作时,则可以在这些方法里面写相关代码。下面我们详细解析一下相关代理方法的执行条件和顺序,以下顺序为在iOS12.4系统下测试所得。

一、APP启动和APP退出

APP启动和APP退出

二、APP进入桌面和从桌面进入APP

APP进入后台和后台进入APP

三、APP从前台进入应用切换状态和从应用切换状态进入前台

APP应用切换

四、APP在前台显示或隐藏系统控制中心

显示控制中心

五、APP在前台显示或隐藏推送中心

显示推送中心

六、测试demo地址

https://github.com/XMSECODE/ESCAPPStateDemo

相关文章

  • iOS APP状态说明

    我们创建一个iOS新项目的时候,系统会默认创建一个AppDelegate类,并实现UIApplicationDel...

  • iOS App状态相关文章

    应用程序挂起、复原与终止— IOS开发 ios上的app运行状态的几种理解 iOS app状态及其多任务处理 io...

  • App的不同状态

    一:App的不同状态 对于iOS app 来说,知道app当前的状态是至关重要的,因为iOS对系统资源有着相当严格...

  • iOS 点击推送跳转详情页

    系统 API :iOS < 7、 7 <= iOS < 10、 iOS >= 10app 状态:后台运行、 前台...

  • iOS应用程序生命周期

    iOS应用程序生命周期 App状态变化历史: 在iOS4之前的App时代,整个界面只允许一个App处于运行状态,而...

  • iOS 生命周期

    一、APP状态APP状态可分为五种,分别如下: 1、Not running 未运行,即APP没有启动或者被iOS系...

  • iOS APP 状态恢复

    前言 最近项目需求加上状态恢复, 记得之前在书上看过, 这次单独抽出这个功能实现详细梳理一下, 方便自己温习一下,...

  • iOS查看App状态

    1、 https://itunesconnect.apple.com/2、我的 App3、点击图片4、找到App ...

  • iOS app活跃状态

    // 即将失去活动状态的时候调用(失去焦点, 不可交互) (void)applicationWillResignA...

  • App 跳转到 AppStore

    话不多少,今天恰好写到ios跳转到app store,遇到一些问题,如下图文说明 1: iOS如何获取app St...

网友评论

      本文标题:iOS APP状态说明

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