Storyboard启动过程

原文:http://course.gdou.com/blog/Blog.pzs/archive/2012/2/5/10929.html


iOS 5 环境下,使用 Storyboard 的应用程序结构如下:

@interface AppDelegate : UIResponder <UIApplicationDelegate>

 

@property (strongnonatomicUIWindow *window;

@end 

程序代理的实现文件中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

{

    // Override point for customization after application launch.

    return YES;

}

 

main.m x 文件:

 

int main(int argc, char *argv[])

{

    @autoreleasepool {

        return UIApplicationMain(argc, argv, nilNSStringFromClass([AppDelegate class]));

    }

}

 
程序启动过程如下:
  1. UIApplicationMain 函数调用创建一个 UIApplication 对象及程序代理对象(本例为 AppDelegate)
  2. UIApplication 对象扫描 Info.plist 文件,将其中 Mainstoryboard file base name 所指定的 Storyboard 文件装入(通常为:MainStoryboard.storyboard) 
  3. UIApplication 对象从程序代理对象中获取窗口对象UIWindow(或创建一个UIWindow 新实例并将其与程序代理对象相关联)
  4. 将Storyboard 文件中 initial view controller 属性所指定的UIViewController 实例化,并将它赋予为 UIWindow 的root view controller
  5. 向程序代理对象发送  application:didFinishLaunchingWithOptions: 消息,以便程序员做自己的初始化工作

If you define a main storyboard in your project, iOS automatically does a lot of work for you to set up your app. When your app calls the UIApplicationMain function, iOS performs the following actions:

  1. It instantiates the app delegate based on the class name you passed into the UIApplicationMain function.
  2. It creates a new window attached to the main screen.
  3. If your app delegate implements a window property, iOS sets this property to the new window.
  4. It loads the main storyboard referenced in the app’s information property list file.
  5. It instantiates the main storyboard’s initial view controller.
  6. It sets the window’s rootViewController property to the new view controller.
  7. It calls the app delegate’s application:didFinishLaunchingWithOptions: method. Your app delegate is expected to configure the initial view controller (and its children, if it is a container view controller).
  8. It calls the window’s makeKeyAndVisible method to display the window. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值