loadNibNamed如何? [英] How does loadNibNamed?

查看:216
本文介绍了loadNibNamed如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数示例中,未使用 loadNibNamed 值的返回值,因此我猜它使用了owner参数。但它如何工作并与所有者对象建立连接?为了以这种方式加载笔尖,我的所有者类应满足哪些要求?

In most of the samples the return value from loadNibNamed value is not used, so I guess it's using the owner argument. But how does it work and make the connection to the owner object? What kind of requirements should my owner class meet in order to load a nib in such way?

我能猜出的唯一要求是


  1. 所有者类必须在nib文件中定义出口或许多对象

  2. nib文件的所有者应该设置到加载nib的类,然后 loadNibNamed 中的所有者param可以设置为 self

  3. nib文件应该将所有连接设置为在所有者类中定义的出口

  1. the owner class must have an outlet defined on or many of the objects in the nib file
  2. the nib file's owner SHOULD be set to the class where the nib is being loaded, then the owner param in loadNibNamed can be set to self
  3. the nib file should have all connections set to outlets defined in owner class

我是否在我的权利中在使用 loadNibNamed 时,我还需要考虑其他什么?

Am I right in my assumptions or is there anything else I have to consider while using loadNibNamed?

推荐答案

您对所需内容有基本的了解,但您也应该考虑内存管理(iPhone与Mac略有不同)。要真正了解此方法的用途,您应该阅读资源编程指南的noreferrer> Nib文件部分。它涵盖了用于建立连接的实际方法(可能很重要),以及各种对象在完成时将具有的保留计数。同样,这些在Mac和iPhone之间略有不同。 iPhone通常会提高处理nib对象的一致性。

You have a basic understanding of what is required, though you should also consider memory management (which is slightly different for iPhone versus Mac). To really understand what is going on with this method, you should read the Nib Files section of the Resources Programming Guide. It covers the actual methods used to make the connections (which can be important), and the retain counts that various objects will have when it is done. Again, these are all slightly different between Mac and iPhone. iPhone has generally improved the consistency of how nib objects are handled.

为了更好的衡量,我总是建议人们阅读内存管理编程指南的.com / iphone / library / documentation / cocoa / conceptual / memorymgmt / Articles / mmNibObjects.htmlrel =noreferrer> Nib对象的内存管理。无论您是否使用较低级别的方法,这都是至关重要的。

For good measure, I always recommend that people read Memory Management of Nib Objects from the Memory Management Programming Guide. It's critical reading whether you use the lower-level methods or not.

这篇关于loadNibNamed如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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