iOS学习 应用程序对象介绍AppDelegate 信息提醒

2023-10-07 03:18

本文主要是介绍iOS学习 应用程序对象介绍AppDelegate 信息提醒,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

#import "AppDelegate.h"


@interface AppDelegate ()


@end


@implementation AppDelegate


#pragma mark - 应用程序加载完成

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

    

    NSLog(@"应用程序加载完成");

    

    // Override point for customization after application launch.

    return YES;

}


#pragma mark -  即将非活跃状态(即将失去焦点)

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

    

    NSLog(@"即将非活跃状态(即将失去焦点)");

    // 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 open Graphics Library

}


#pragma mark - 应用程序进入后台

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

    

    NSLog(@"应用程序进入后台");

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

}


#pragma mark - 即将进入前台

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

    

    NSLog(@"即将进入前台");

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

}


#pragma mark - 称为活跃状态(获取焦点)可以让用户操作

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

    

    NSLog(@"称为活跃状态(获取焦点)可以让用户操作");

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

}


#pragma mark - 应用即将被销毁的时候调用

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

    

    NSLog(@"应用即将被销毁的时候调用");

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

}


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

    

    NSLog(@"接收到内存警告");


}

@end


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    

}


- (IBAction)btnClick {

    

    // 单例对象

    UIApplication *app1 = [UIApplication sharedApplication];

    

//    NSLog(@"%@", app1);

    

    UIApplication *app2 = [UIApplication sharedApplication];

//    NSLog(@"%@", app2);

    

    // networkActivityIndicatorVisible 联网指示器

//    app1.networkActivityIndicatorVisible = YES;

    app1.networkActivityIndicatorVisible = !app1.isNetworkActivityIndicatorVisible;

    

    // applicationIconBadgeNumber 应用头像上的数字

    /**

     // IOS 8.0以后, 应用必须注册用户通知,在设置数字之前

     In iOS 8.0 and later, your application must register for user notifications using -[UIApplication registerUserNotificationSettings:] before being able to set the icon badge.

     */

//    SEL;


    // 判断手机系统的版本

    double systemVersion = [[UIDevice currentDevice].systemVersion doubleValue];

    

    if (systemVersion >= 8.0) {

        // 注册用户通知,只提醒一次

        UIUserNotificationCategory *category = [[UIUserNotificationCategory alloc] init];

        NSSet *set = [NSSet setWithObject:category];

        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:set];

        

        [app1 registerUserNotificationSettings:settings];

    }

    

    app1.applicationIconBadgeNumber = 10;

    

    

    app1.statusBarHidden = YES;

}


// 隐藏状态栏

//- (BOOL)prefersStatusBarHidden {

//

//    return YES;

//}


@end

这篇关于iOS学习 应用程序对象介绍AppDelegate 信息提醒的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/155699

相关文章

Pytest多环境切换的常见方法介绍

《Pytest多环境切换的常见方法介绍》Pytest作为自动化测试的主力框架,如何实现本地、测试、预发、生产环境的灵活切换,本文总结了通过pytest框架实现自由环境切换的几种方法,大家可以根据需要进... 目录1.pytest-base-url2.hooks函数3.yml和fixture结论你是否也遇到过

在java中如何将inputStream对象转换为File对象(不生成本地文件)

《在java中如何将inputStream对象转换为File对象(不生成本地文件)》:本文主要介绍在java中如何将inputStream对象转换为File对象(不生成本地文件),具有很好的参考价... 目录需求说明问题解决总结需求说明在后端中通过POI生成Excel文件流,将输出流(outputStre

MySQL中慢SQL优化的不同方式介绍

《MySQL中慢SQL优化的不同方式介绍》慢SQL的优化,主要从两个方面考虑,SQL语句本身的优化,以及数据库设计的优化,下面小编就来给大家介绍一下有哪些方式可以优化慢SQL吧... 目录避免不必要的列分页优化索引优化JOIN 的优化排序优化UNION 优化慢 SQL 的优化,主要从两个方面考虑,SQL 语

C++中函数模板与类模板的简单使用及区别介绍

《C++中函数模板与类模板的简单使用及区别介绍》这篇文章介绍了C++中的模板机制,包括函数模板和类模板的概念、语法和实际应用,函数模板通过类型参数实现泛型操作,而类模板允许创建可处理多种数据类型的类,... 目录一、函数模板定义语法真实示例二、类模板三、关键区别四、注意事项 ‌在C++中,模板是实现泛型编程

Python实现html转png的完美方案介绍

《Python实现html转png的完美方案介绍》这篇文章主要为大家详细介绍了如何使用Python实现html转png功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 1.增强稳定性与错误处理建议使用三层异常捕获结构:try: with sync_playwright(

Java使用多线程处理未知任务数的方案介绍

《Java使用多线程处理未知任务数的方案介绍》这篇文章主要为大家详细介绍了Java如何使用多线程实现处理未知任务数,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 知道任务个数,你可以定义好线程数规则,生成线程数去跑代码说明:1.虚拟线程池:使用 Executors.newVir

一文详解SQL Server如何跟踪自动统计信息更新

《一文详解SQLServer如何跟踪自动统计信息更新》SQLServer数据库中,我们都清楚统计信息对于优化器来说非常重要,所以本文就来和大家简单聊一聊SQLServer如何跟踪自动统计信息更新吧... SQL Server数据库中,我们都清楚统计信息对于优化器来说非常重要。一般情况下,我们会开启"自动更新

Python如何获取域名的SSL证书信息和到期时间

《Python如何获取域名的SSL证书信息和到期时间》在当今互联网时代,SSL证书的重要性不言而喻,它不仅为用户提供了安全的连接,还能提高网站的搜索引擎排名,那我们怎么才能通过Python获取域名的S... 目录了解SSL证书的基本概念使用python库来抓取SSL证书信息安装必要的库编写获取SSL证书信息

C#原型模式之如何通过克隆对象来优化创建过程

《C#原型模式之如何通过克隆对象来优化创建过程》原型模式是一种创建型设计模式,通过克隆现有对象来创建新对象,避免重复的创建成本和复杂的初始化过程,它适用于对象创建过程复杂、需要大量相似对象或避免重复初... 目录什么是原型模式?原型模式的工作原理C#中如何实现原型模式?1. 定义原型接口2. 实现原型接口3

Java进阶学习之如何开启远程调式

《Java进阶学习之如何开启远程调式》Java开发中的远程调试是一项至关重要的技能,特别是在处理生产环境的问题或者协作开发时,:本文主要介绍Java进阶学习之如何开启远程调式的相关资料,需要的朋友... 目录概述Java远程调试的开启与底层原理开启Java远程调试底层原理JVM参数总结&nbsMbKKXJx