一个UI程序开始的代码函数导读
#import "QFAppDelegate.h" @implementation QFAppDelegate //最后一个执行的初始化函数
//主要做一些启动之前的初始化操作
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"didFinishLaunchingWithOptions"); //实例化窗口
//initWithFrame 初始化位置和大小
//[UIScreen mainScreen] 获取屏幕对象
//[[UIScreen mainScreen] bounds] 获取屏幕边界,包含起始位置和屏幕大小
//CGRect 矩形大小
//CGPoint 坐标位置
//CGSize 大小
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//设置窗口背景颜色
//UIColor 颜色对象
self.window.backgroundColor = [UIColor whiteColor];
//自定义颜色 RGBa
//Red,Green,Blue 取值范围 0.0~1.0
//Aplha 取值范围 0.0~1.0 0 为不透明
UIColor *c = [UIColor colorWithRed:arc4random() % / 255.0
green:arc4random() % / 255.0
blue:arc4random() % / 255.0
alpha:1.0]; self.window.backgroundColor = c; //显示窗口
[self.window makeKeyAndVisible]; //UIView
//在屏幕上看得见摸得着的东西都是UIView的子类 return YES;
} //即将进入后台
//停止一些正在执行的操作
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"applicationWillResignActive");
// 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.
} //已经进入后台
//尽量多的保存app的当前状态
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"applicationDidEnterBackground");
// 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.
} //即将进入前台
//恢复之前进入后台时候的状态
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"applicationWillEnterForeground");
// 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.
} //已经在前台
//重新启动之前暂停的任务
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"applicationDidBecomeActive");
// 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.
} //程序退出
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"applicationWillTerminate");
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} @end
一个UI程序开始的代码函数导读的更多相关文章
- UI基础:UI程序执行顺序(UIApplicationMain()函数),自定义视图 分类: iOS学习-UI 2015-07-02 22:09 68人阅读 评论(0) 收藏
UI程序的一般执行顺序: 先进入main里面,执行函数UIApplicationMain(),通过该函数创建应用程序对象和指定其代理并实现监听,当执行函数UIApplicationMain()时还会做 ...
- 我的第一个Python程序,定义主函数,eval、format函数详解,
程序实例: #第一个py小程序 def main(): f = eval(input("输入一个数值:")) p=f*(5/9) print("现在的值为:{0:3.3f ...
- Qt-第一个QML程序-2-关键代码分析,TEXT,Image,Mouseare
qml语言开始写的时候有点不习惯,后面用的多了感觉很好,很顺手,用于快速搭建项目界面,真的很好. 目前用到的还是比较简单的 隐藏标题栏,而依附任务栏 flags: Qt.Window | Qt.Fra ...
- CodeGuide 300+文档、100+代码库,一个指导程序员写代码的,Github 仓库开源啦!
作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.路怎样走,让你们自己挑 B站 视频:https://www.bilibili.com/vi ...
- 【C++探索之旅】第一部分第三课:第一个C++程序
内容简介 1.第一部分第三课:第一个C++程序 2.第一部分第四课预告:内存的使用 第一个C++程序 经过上两课之后,我们已经知道了什么是编程,编程的语言,编程的必要软件,C++是什么,我们也安装了适 ...
- 三、第一个cocos2d程序的代码分析
http://blog.csdn.net/q199109106q/article/details/8591706 在第一讲中已经新建了第一个cocos2d程序,运行效果如下: 在这讲中我们来分析下里面 ...
- 【C语言】03-第一个C程序代码分析
前面我们已经创建了一个C程序,接下来分析一下里面的代码. 项目结构如下: 一.代码分析 打开项目中的main.c文件(C程序的源文件拓展名为.c),可以发现它是第一个C程序中的唯一一个源文件,代码如下 ...
- 【C语言】01-第一个c程序代码分析
创建了一个C程序,接下来分析一下里面的代码. 项目结构如下: 一.代码分析 打开项目中的main.c文件(C程序的源文件拓展名为.c),可以发现它是第一个C程序中的唯一一个源文件,代码如下: 1 #i ...
- Python_代码练习_写一个判断是否为小数的函数
这两天在学习函数,练习写一个判断是否为小数的函数,看起来蛮简单的,飞速写完很是得意,然后测了一下,发现差得好多呀,这个并不像想象那样简单,我得到的教训是,想要把一个需求哪怕再小的需求考虑周全,都不是件 ...
随机推荐
- shell脚本1——变量 $、read、``
与Shell变量相关的几个命令: 变量只在当前Shell中生效. source 这个命令让脚本影响他们父Shell的环境(. 可以代替source命令) export 这个命令可以让脚本影响其子She ...
- pod删除主要流程源码解析
本文以v1.12版本进行分析 当一个pod删除时,client端向apiserver发送请求,apiserver将pod的deletionTimestamp打上时间.kubelet watch到该事件 ...
- 【开发工具 - MySQL】之不能插入中文的问题
新安装的MySQL数据库,在安装的时候设置了字体为UTF8,但在使用insert语句插入中文的时候还是会报错. 具体解决方法:在MySQL控制台中输入以下设置代码: SET character_set ...
- node.js多进程架构
node.js是单进程应用,要充分利用多核cpu的性能,就需要用到多进程架构. 作为web服务器,不能多个进程创建不同的socket文件描述符去accept网络请求, 有经验的同学知道,如果端口被占用 ...
- Feign超时设置
转-原文:https://xli1224.github.io/2017/09/22/configure-feign/ 在分析 Feign 源码的时候,我们看到 Feign 构建代理对象是分了几层的,一 ...
- 理解Redis的单线程模式
0.概述 本文基于的Redis版本为4.0以下,在Redis更高版本中并不是完全的单线程了,增加了BIO线程,本文主要讲述主工作线程的单线程模式. 通过本文将了解到以下内容: Redis服务器采用单线 ...
- Android组合Windows环境下Frida的安装步骤
Frida是什么 我觉得官网已经说得很清楚了.简单的说就是一款动态代码检测工具,可用于各种系统,这里的主要用途是动态检测Android代码,配合Windows系统环境使用. Frida ...
- 如何在DevOps中实施连续测试
在过去的十年中,对软件开发的需求已急剧发展.软件已成为公司获得竞争优势的关键优势,特别是如果您的公司属于SaaS范畴.通过在SDLC中实施瀑布等传统流程,组织现在正在向敏捷过渡,以便以更快的速度在市场 ...
- 安装破解版IntelliJ IDEA
1.下载IntelliJ IDEA http://www.jetbrains.com/idea/download/#section=windows 选择Ultimate版本 2.注册码破解 http: ...
- 0-N-0计数的优化写法
采用取余%的写法: int i = 0; while( 1 ) { printf( "%d\n", i ); i = ( i + 1 ) % ( N + 1 );}