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

相关文章

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

Java深度学习库DJL实现Python的NumPy方式

《Java深度学习库DJL实现Python的NumPy方式》本文介绍了DJL库的背景和基本功能,包括NDArray的创建、数学运算、数据获取和设置等,同时,还展示了如何使用NDArray进行数据预处理... 目录1 NDArray 的背景介绍1.1 架构2 JavaDJL使用2.1 安装DJL2.2 基本操

JSON字符串转成java的Map对象详细步骤

《JSON字符串转成java的Map对象详细步骤》:本文主要介绍如何将JSON字符串转换为Java对象的步骤,包括定义Element类、使用Jackson库解析JSON和添加依赖,文中通过代码介绍... 目录步骤 1: 定义 Element 类步骤 2: 使用 Jackson 库解析 jsON步骤 3: 添

四种Flutter子页面向父组件传递数据的方法介绍

《四种Flutter子页面向父组件传递数据的方法介绍》在Flutter中,如果父组件需要调用子组件的方法,可以通过常用的四种方式实现,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录方法 1:使用 GlobalKey 和 State 调用子组件方法方法 2:通过回调函数(Callb

C#实现系统信息监控与获取功能

《C#实现系统信息监控与获取功能》在C#开发的众多应用场景中,获取系统信息以及监控用户操作有着广泛的用途,比如在系统性能优化工具中,需要实时读取CPU、GPU资源信息,本文将详细介绍如何使用C#来实现... 目录前言一、C# 监控键盘1. 原理与实现思路2. 代码实现二、读取 CPU、GPU 资源信息1.

Python进阶之Excel基本操作介绍

《Python进阶之Excel基本操作介绍》在现实中,很多工作都需要与数据打交道,Excel作为常用的数据处理工具,一直备受人们的青睐,本文主要为大家介绍了一些Python中Excel的基本操作,希望... 目录概述写入使用 xlwt使用 XlsxWriter读取修改概述在现实中,很多工作都需要与数据打交

在C#中获取端口号与系统信息的高效实践

《在C#中获取端口号与系统信息的高效实践》在现代软件开发中,尤其是系统管理、运维、监控和性能优化等场景中,了解计算机硬件和网络的状态至关重要,C#作为一种广泛应用的编程语言,提供了丰富的API来帮助开... 目录引言1. 获取端口号信息1.1 获取活动的 TCP 和 UDP 连接说明:应用场景:2. 获取硬

SpringBoot使用Apache Tika检测敏感信息

《SpringBoot使用ApacheTika检测敏感信息》ApacheTika是一个功能强大的内容分析工具,它能够从多种文件格式中提取文本、元数据以及其他结构化信息,下面我们来看看如何使用Ap... 目录Tika 主要特性1. 多格式支持2. 自动文件类型检测3. 文本和元数据提取4. 支持 OCR(光学

JAVA系统中Spring Boot应用程序的配置文件application.yml使用详解

《JAVA系统中SpringBoot应用程序的配置文件application.yml使用详解》:本文主要介绍JAVA系统中SpringBoot应用程序的配置文件application.yml的... 目录文件路径文件内容解释1. Server 配置2. Spring 配置3. Logging 配置4. Ma

java脚本使用不同版本jdk的说明介绍

《java脚本使用不同版本jdk的说明介绍》本文介绍了在Java中执行JavaScript脚本的几种方式,包括使用ScriptEngine、Nashorn和GraalVM,ScriptEngine适用... 目录Java脚本使用不同版本jdk的说明1.使用ScriptEngine执行javascript2.