一个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_代码练习_写一个判断是否为小数的函数
这两天在学习函数,练习写一个判断是否为小数的函数,看起来蛮简单的,飞速写完很是得意,然后测了一下,发现差得好多呀,这个并不像想象那样简单,我得到的教训是,想要把一个需求哪怕再小的需求考虑周全,都不是件 ...
随机推荐
- objc反汇编分析,手工逆向libsystem_blocks.dylib
上一篇<block函数块为何物?>介绍了在函数中定义的block函数块的反汇编实现,我在文中再三指出__block变量和block函数块自始还都是stack-based的,还不完全适合在离 ...
- myBaits持久性框架
动态 SQL 博客交流群:1018996617 动态 SQL MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL ...
- 【2018寒假集训 Day2】【动态规划】抢金块
抢金块 输入文件:gold.in 输出文件:gold.out 问题描述: 地面上有一些格子,每个格子上面都有金块,但不同格子上的金块有不同的价值,你一次可以跳S至T步 .如果S=2,T=4.你就可以跳 ...
- 预分配——fallocate的前世今生
最近比较懒,还是加班写点东西吧,不然过段时间又把这些整理的东西弄丢了. 写什么呢?写一些跟工作相关的吧!因为笔者从事多媒体录像相关的开发工作,因此常常涉及到优化写卡策略.提升写卡性能相关的方面的事情. ...
- 聚类-DBSCAN基于密度的空间聚类
1.DBSCAN介绍 DBSCAN(Density-Based Spatial Clustering of Applications with Noise,具有噪声的基于密度的聚类方法)是一种基于密度 ...
- 深入理解inode和硬链接和软连接和挂载点
inode 一.inode是什么? 理解inode,要从文件储存说起. 扇区 文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector).每个扇区储存512字节(相当于0.5 ...
- bs4-爬取小说
bs4 bs4有两种运行方式一种是处理本地资源,一种是处理网络资源 本地 from bs4 import BeautifulSoup if __name__ == '__main__': fr = o ...
- 面试官:JVM锁优化都优化了啥?
从JDK1.6开始,JVM对锁进行了各种优化,目的就是为了在线程间更高效的共享数据和解决互斥同步的问题.从锁优化的话题开始,可以引申出很多考点面试题,比如锁优化的技术.各优化技术的细节.CAS实现原理 ...
- exc_bad_instruction(code=EXC_I386_INVOP,subcode=0x0) 错误
对象存储异常 对象存储要遵守NSCoding协议 #import "EmotionModel.h" @interface EmotionModel()<NSCoding> ...
- jQuery实现倒计时重新发送短信验证码功能示例
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...