[raywenderlich教程]
非常詳細的圖文入門教程http://www.raywenderlich.com/81879/storyboards-tutorial-swift-part-1
因為太長了 所以只放一些我覺得很有用的內容的翻譯
?
The single View Controller you defined was set as the Initial View Controller – but how did the app load it? Take a peek at the application delegate to find the answer. Open up?AppDelegate.swift?and you’ll see the source starts with this:
你定義的View Controller被設置為初始視圖控制器-但是app是怎么裝載的呢?看一眼應用委托來找答案。打開AppDelegate.swift然后你就會發現源代碼是這樣開始的
| import UIKit@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {// Override point for customization after application launch.return true} |
The?@UIApplicationMain?attribute at the top of the file designates the AppDelegate class as the entry point for the module. It is a requirement for using storyboards that your application delegate inherits from?UIResponder?and that it has a?UIWindow?property. All the methods are practically empty. Evenapplication(_:didFinishLaunchingWithOptions:)?simply returns true.
文件頂部的@UIApplicationMain 屬性指定了AppDelegate 類作為模塊的入口。使用你的應用指定從UIResponder繼承來有UIWindows屬性的storyboards是必須的。所有的方法實際上是空的。甚至 application(_:didFinishLaunchingWithOptions:)也是簡單地返回ture值。
The secret is in the Info.plist file. Click on?Info.plist?(you can find it in the Supporting Files group) and you’ll see this:
秘密藏在Info.plist文件里。點擊Info.plist(可以在Supporting Files 分組里) 然后你將會看到這個
Storyboard apps use the key?UIMainStoryboardFile, also known as “Main storyboard file base name”, to specify the name of the storyboard that must be loaded when the app starts. When this setting is present,?UIApplication?will load the named storyboard file, automatically instantiate the “Initial View Controller” from that storyboard, and then put that controller’s view into a new?UIWindow?object.
Storyboard 應用使用鍵 UIMainStoryboardFile,也命名為"Main storyboard file base name(主storyboard文件基礎名)",規定了應用啟動時必須加載的storyboard的名字。當這個設置被呈現的時候,UIApplication將會載入指定的storyboard文件,自動地從那個storyboard實例化"Initial View Controller(初始視圖控制器)",然后把那個控制器的視圖放入一個新的UIWindows對象。
You can also see this in the?Project Settings?under the General tab and?Deployment Info?section:
你也可以在項目設置中的General 表單Deployment Info 部分看到這個
Now to create the real Ratings app with several view controllers.
?
轉載于:https://www.cnblogs.com/baaingSheep/p/4280523.html
總結
以上是生活随笔為你收集整理的[raywenderlich教程]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浏览器的一个请求从发送到返回都经历了什么
- 下一篇: IDEA @Override is no