接口生成器项目何时确切实例化? [英] when exactly do Interface Builder items get instantiated?

查看:63
本文介绍了接口生成器项目何时确切实例化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我从XCode4中的模板创建了一个基于导航的应用程序,然后在MainWindow.xib中将有一个导航控制器,该导航控制器作为子代具有RootViewController.

Say I create a navigation based application from the template in XCode4, then there will be in the MainWindow.xib a Navigation Controller, which has as a child the RootViewController.

那么什么时候才能做到

  1. 要创建RootViewController的实例吗?
  2. 该实例与导航控制器的孩子相关联吗?

尤其是在与applicationDelegate"didFinishLaunchingWithOptions"方法的时间有关时以及它何时发生.

In particular when in relation to the timing for the applicationDelegate "didFinishLaunchingWithOptions" method and when it occurs.

推荐答案

如plist中所示,MainWindow是Main nib文件的基本名称.因此,将基于plist生成一些隐藏的代码,以在启动时加载主窗口nib文件.这发生在didFinishLaunchingWithOptions之前.

As given in the plist the MainWindow is the Main nib file base name. So there is some hidden code which will be generated based on the plist to load the main window nib file on startup. This happens before didFinishLaunchingWithOptions.

一旦载入MainWindow笔尖,就会在后台完成一系列操作,请参考

As soon as the MainWindow nib is loaded there is a cascade of things that are done in the background, please refer to The Nib Object Life Cycle in the Resource Programming Guide.

其中一个步骤是

取消存档笔尖对象图 数据并实例化对象.

It unarchives the nib object graph data and instantiates the objects.

然后几乎可以做到了:

它将awakeFromNib消息发送给 笔尖中的适当对象 定义匹配的文件 选择器: ... 在iOS中,此消息仅发送给 以前的接口对象 由笔尖加载代码实例化. 它不会先发送给文件的所有者 响应者或任何其他代理对象.

It sends an awakeFromNib message to the appropriate objects in the nib file that define the matching selector: ... In iOS, this message is sent only to the interface objects that were instantiated by the nib-loading code. It is not sent to File’s Owner, First Responder, or any other proxy objects.

您可以掌握的第一种方法是awakeFromNib.

The first method you can get a grip on is awakeFromNib.

要回答您的三个问题:

  1. 在加载MainWindo nib文件期间
  2. 是的,看看界面生成器中的nib文件
  3. 这一切都发生在didFinishLaunchingWithOptions
  4. 之前

这篇关于接口生成器项目何时确切实例化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆