[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 分组里) 然后你将会看到这个

Info.plist

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 部分看到这个

Project Settings

Now to create the real Ratings app with several view controllers.

 

转载于:https://www.cnblogs.com/baaingSheep/p/4280523.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值