非常详细的图文入门教程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.