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

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

性能测试介绍

性能测试是一种测试方法,旨在评估系统、应用程序或组件在现实场景中的性能表现和可靠性。它通常用于衡量系统在不同负载条件下的响应时间、吞吐量、资源利用率、稳定性和可扩展性等关键指标。 为什么要进行性能测试 通过性能测试,可以确定系统是否能够满足预期的性能要求,找出性能瓶颈和潜在的问题,并进行优化和调整。 发现性能瓶颈:性能测试可以帮助发现系统的性能瓶颈,即系统在高负载或高并发情况下可能出现的问题

水位雨量在线监测系统概述及应用介绍

在当今社会,随着科技的飞速发展,各种智能监测系统已成为保障公共安全、促进资源管理和环境保护的重要工具。其中,水位雨量在线监测系统作为自然灾害预警、水资源管理及水利工程运行的关键技术,其重要性不言而喻。 一、水位雨量在线监测系统的基本原理 水位雨量在线监测系统主要由数据采集单元、数据传输网络、数据处理中心及用户终端四大部分构成,形成了一个完整的闭环系统。 数据采集单元:这是系统的“眼睛”,

Hadoop数据压缩使用介绍

一、压缩原则 (1)运算密集型的Job,少用压缩 (2)IO密集型的Job,多用压缩 二、压缩算法比较 三、压缩位置选择 四、压缩参数配置 1)为了支持多种压缩/解压缩算法,Hadoop引入了编码/解码器 2)要在Hadoop中启用压缩,可以配置如下参数

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

让树莓派智能语音助手实现定时提醒功能

最初的时候是想直接在rasa 的chatbot上实现,因为rasa本身是带有remindschedule模块的。不过经过一番折腾后,忽然发现,chatbot上实现的定时,语音助手不一定会有响应。因为,我目前语音助手的代码设置了长时间无应答会结束对话,这样一来,chatbot定时提醒的触发就不会被语音助手获悉。那怎么让语音助手也具有定时提醒功能呢? 我最后选择的方法是用threading.Time

安卓链接正常显示,ios#符被转义%23导致链接访问404

原因分析: url中含有特殊字符 中文未编码 都有可能导致URL转换失败,所以需要对url编码处理  如下: guard let allowUrl = webUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {return} 后面发现当url中有#号时,会被误伤转义为%23,导致链接无法访问

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]