The Swift Code主要是通过编写代码来完成应用程序的实现,使我们更能够深入的了解其编程语言实现的原理.也能够辅助更快的使用XCODE开发应用程序.
这篇文章主要是讲解启动应用程序从代码入口.
其 实这里主要是通过注解来实现的,新建IOS swift项目的时候,会生成一个AppDelegate文件,这个文件就是应用程序的代码入口,在声明类的同时加入了注解 @UIApplicationMain,表明这个应用程序.其实在这之前,我们必须在配置文件里设置启动入口为Main
以下讲解,我们在代码里做讲解,大家可以试试在模拟里调试
import UIKit @UIApplicationMain class 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
相关推荐
The Swift Programming Language (Apple Inc) Swift 4 epub+mobi+azw3
swift code查询工具 可以查询swift code 从swift.com上下载下来的
最新版的用swift4 开发ios应用,好东东,开发必备学习 原版 Beginning iPhone Development with Swift 4: Exploring the iOS SDK
30个用于自学的迷你Swift应用程序
Ashen:在Swift中编写终端应用程序的框架,基于Elm (非常类似于React的模式).
Hi大家好, 鉴于《The Swift Programming Language》中文文档版本繁杂,避免大家因为版本问题引起学习不便。@未来眼之老码团队 会定期发布最新的中文文档。大家有任何问题欢迎垂询! BR OldCoder Team
epub格式 直接导入ibooks观看 The Swift Programming Language (Swift 4)方式,....摘要居然要大于100个子,这是不是...
《The Swift Programming Language》中文版
Swift4.0.3官方原版文档,pub格式,The Swift Programming Language
The Swift Programming Language(Swift3.0中文版) The Swift Programming Language(Swift3.0中文版) The Swift Programming Language(Swift3.0中文版)
The Swift Programming Language (Swift 4.0.3) ,swift官方教程
使用 Swift 开发 iOS 应用程序时需要考虑的几个事项,以及几个精典例子。
“The Swift Programming Language 中文版”“现在是6月12日凌晨4:38,我用了整整一晚上的时间来进行最后的校对,终于可以在12日拿出一个可以发布的版本。9天时间,1317个 Star,310个 Fork,超过30人参与翻译和校对...
Swift 2019演示应用程序,可将无深度2D图像转换为纵向模式
Swift is a fantastic way to write software, whether it’s for phones, desktops, servers, or anything else that runs code. It’s a safe, fast, and interactive programming language that combines the ...
code: 在Go中构建iOS和Android应用程序的框架
The Swift Programming Language is the authoritative reference for Swift, offering a guided tour, a comprehensive guide, and a formal reference of the language. You can read the book here:
各大银行Swift Code代码表银行电汇码
The Swift Programming Language英文原版
stanford developing ios 9 apps with swift code down,斯坦佛白胡子老师iOS9 代码及视频下载地址