The Swift Code之应用程序的启动过程
来源:互联网 发布:淘宝网忘了密码怎么办 编辑:程序博客网 时间:2024/06/08 14:36
The Swift Code主要是通过编写代码来完成应用程序的实现,使我们更能够深入的了解其编程语言实现的原理.也能够辅助更快的使用XCODE开发应用程序.
这篇文章主要是讲解启动应用程序从代码入口.
其实这里主要是通过注解来实现的,新建IOS swift项目的时候,会生成一个AppDelegate文件,这个文件就是应用程序的代码入口,在声明类的同时加入了注解@UIApplicationMain,表明这个应用程序.其实在这之前,我们必须在配置文件里设置启动入口为Main
以下讲解,我们在代码里做讲解,大家可以试试在模拟里调试
import UIKit@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? /*程序未启动时,点击应用程序触发该方法,之后触发applicationDidBecomeActive*/ func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. NSLog("开始启动application........") window = UIWindow(frame: UIScreen.mainScreen().bounds) window?.backgroundColor = UIColor.orangeColor() window?.rootViewController = ViewController() return true } /*点击HOme键后,程序即将进入委托处理(委托给系统处理),紧跟着将会触发 applicationDidEnterBackground 方法*/ func applicationWillResignActive(application: UIApplication) { // 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. NSLog("开始启动applicationWillResignActive........") } /*用户点击了Home按键,程序进入后台处理*/ func applicationDidEnterBackground(application: UIApplication) { // 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. NSLog("开始启动applicationDidEnterBackground........") } /*在应用程序未消亡状态,状态由后台处理,进入前台处理,触发该方法,之后触发applicationDidBecomeActive*/ func applicationWillEnterForeground(application: UIApplication) { // 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. NSLog("开始启动applicationWillEnterForeground........") } /*应用程序进入后,触发该方法*/ func applicationDidBecomeActive(application: UIApplication) { // 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. NSLog("开始启动applicationDidBecomeActive........") } func applicationWillTerminate(application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. NSLog("开始启动applicationWillTerminate........") } }
转载至吴统威的博客:http://www.wutongwei.com/front/infor_showone.tweb?id=87
0 0
- The Swift Code之应用程序的启动过程
- The Swift Code之UITextField的使用,及事件委托
- 应用程序的启动过程
- Windows应用程序的启动过程
- Windows应用程序的启动过程
- Symbian应用程序的启动过程
- C++应用程序的启动过程
- Symbian应用程序的启动过程
- iPhone应用程序的启动过程
- android应用程序的启动过程
- iOS 应用程序的启动过程
- iOS应用程序的启动过程
- The Swift Code之UILabel的创建,以及不同的状态和外观
- The Swift Code之UITextView的创建,以及不同的状态和外观
- The Swift Code之设置UIButton的不同方式创建,以及不同的状态和外观
- THE SWIFT CODE之设置UIBUTTON的不同方式创建,以及不同的状态和外观
- 一个C++应用程序的启动过程
- 一个win32应用程序文件的启动过程
- 关于LINUX权限-bash: ./startup.sh: Permission denied
- nginx源码分析之http解码实现
- android-进阶-黑盒测试
- 15款macbook pro下安装jdk-8
- Maximum Subarray - LeetCode
- The Swift Code之应用程序的启动过程
- Best-First-Search算法
- Java实现最长公共子序列
- 原码, 反码, 补码 详解
- 关于 zend studio 中有些php 内置函数没有提示,或是有‘小黄色感叹号’
- 全志A20电阻屏调试
- phonegap 对键盘的隐藏与显示
- 安装完MySQL 后必须调整的 10 项配置
- Hive总结(十)Hive 输入输出适配类(输出CSV,XML)