#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程序开始的代码函数导读的更多相关文章

  1. UI基础:UI程序执行顺序(UIApplicationMain()函数),自定义视图 分类: iOS学习-UI 2015-07-02 22:09 68人阅读 评论(0) 收藏

    UI程序的一般执行顺序: 先进入main里面,执行函数UIApplicationMain(),通过该函数创建应用程序对象和指定其代理并实现监听,当执行函数UIApplicationMain()时还会做 ...

  2. 我的第一个Python程序,定义主函数,eval、format函数详解,

    程序实例: #第一个py小程序 def main(): f = eval(input("输入一个数值:")) p=f*(5/9) print("现在的值为:{0:3.3f ...

  3. Qt-第一个QML程序-2-关键代码分析,TEXT,Image,Mouseare

    qml语言开始写的时候有点不习惯,后面用的多了感觉很好,很顺手,用于快速搭建项目界面,真的很好. 目前用到的还是比较简单的 隐藏标题栏,而依附任务栏 flags: Qt.Window | Qt.Fra ...

  4. CodeGuide 300+文档、100+代码库,一个指导程序员写代码的,Github 仓库开源啦!

    作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.路怎样走,让你们自己挑 B站 视频:https://www.bilibili.com/vi ...

  5. 【C++探索之旅】第一部分第三课:第一个C++程序

    内容简介 1.第一部分第三课:第一个C++程序 2.第一部分第四课预告:内存的使用 第一个C++程序 经过上两课之后,我们已经知道了什么是编程,编程的语言,编程的必要软件,C++是什么,我们也安装了适 ...

  6. 三、第一个cocos2d程序的代码分析

    http://blog.csdn.net/q199109106q/article/details/8591706 在第一讲中已经新建了第一个cocos2d程序,运行效果如下: 在这讲中我们来分析下里面 ...

  7. 【C语言】03-第一个C程序代码分析

    前面我们已经创建了一个C程序,接下来分析一下里面的代码. 项目结构如下: 一.代码分析 打开项目中的main.c文件(C程序的源文件拓展名为.c),可以发现它是第一个C程序中的唯一一个源文件,代码如下 ...

  8. 【C语言】01-第一个c程序代码分析

    创建了一个C程序,接下来分析一下里面的代码. 项目结构如下: 一.代码分析 打开项目中的main.c文件(C程序的源文件拓展名为.c),可以发现它是第一个C程序中的唯一一个源文件,代码如下: 1 #i ...

  9. Python_代码练习_写一个判断是否为小数的函数

    这两天在学习函数,练习写一个判断是否为小数的函数,看起来蛮简单的,飞速写完很是得意,然后测了一下,发现差得好多呀,这个并不像想象那样简单,我得到的教训是,想要把一个需求哪怕再小的需求考虑周全,都不是件 ...

随机推荐

  1. shell脚本2——控制语句

    1.顺序结构体 命令从上往下顺序执行 2.分支结构体 1)判断真假 test 表达式 或者 [ 表达式 ](必须有空格) 真返回0,假返回1 test的别名是[, 参数是] 判断表达式 记忆 解释 ! ...

  2. (四十四)golang--协程(goroutine)和管道(channel)相结合实例

    统计1-8000之间的素数. 整体框架: 说明:有五个协程,三个管道.其中一个协程用于写入数字到intChan管道中,另外四个用于取出intChan管道中的数字并判断是否是素数,然后将素数写入到pri ...

  3. Hystrix完整配置列表

    前提 Hystrix在2018年11月20日之后已经停止维护,最后一个提交记录是:Latest commit 3cb2158 on 20 Nov 2018,最后一个正式版本为1.5.18.鉴于目前所在 ...

  4. day 23 面向对象中类的成员 和嵌套

    1.类的成员? 变量.方法.属性 class Foo: # 方法 def __init__(self,name): # 实例变量/字段 self.name = name # 方法 def func(s ...

  5. day03_正则表达式

    1.数据分类 数据的分类 ​ 定义:数据以行为单位,每一个数据表示一个实体的信息.每一行数据的属性都是一样的. ​ 常见的结构化数据为关系型数据库存储数据. 半结构化数据 ​ 定义:结构化数据的另一种 ...

  6. Linux服务和systemctl详解

    定义 A Linux service is an application (or set of applications) that runs in the background waiting to ...

  7. wordpress 获取指定作者或者文章的所有评论数量

    wordpress 获取指定作者或者文章的所有评论数量 <?php $args = array( 'post_author' => '' // fill in post author ID ...

  8. python基础-网络编程part02

    TCP协议 TCP是传输控制协议,建立双向通道. 三次握手,建立连接 客户端向服务端发送建立连接的请求 服务端接收请求返回确认信息给客户端,并向客户端发送建立连接的请求 客户端接收请求返回确认信息给服 ...

  9. 获取Zabbix 中资源的使用率

    import pymysql as MySQLdb import time import datetime import xlsxwriter # zabbix数据库信息: zdbhost = 'xx ...

  10. MySQL双日志

    InnoDB引擎的redo log日志 解决什么问题? 我们每次更新数据如果都要直接写到硬盘存储的话,如果更新数据频繁的话,整个过程的Io成本和查找成本都会很高(比方说每次启动磁盘,平均的寻找数据时间 ...