Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2087855
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类:

2009-06-12 16:51:02

1, Objects Can Be Embedded In Nib File
  In general, following objects can be embedded in Nib file:
  A) Visual Objects
    * Window
    * View
    * Menu

  B) Non-Visual Objects
    * View Controller
    * Any Other NSObject

2, Load Nib File
2.1, Behavior
  When Nib file is loaded, system will create instances of objects embedded in Nib file expect File's Owner. The File’s Owner is a proxy object that is not created when the nib file is loaded; Instead, you create this object in your code and pass it to the nib-loading code (About how to pass File's Owner object when Nib file is loaded, please refer to following section "How To Load Nib File).
  So, if you want Nib-load system to create objects (such as view controller, window, view, customized view, menu, or other objects) automatically, you just need to add objects into Nib file, and to create outlet connections to them via File's Owner, once the Nib file is loaded, you can access them.

2.2, How To Load Nib Files
  (Refer to "Resource Programming Guide" (URL: http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html#//apple_ref/doc/uid/10000051i-CH1-SW1)
  A) Load via NSBundle (This is available after iPhone OS 2.0)
     In this way, you can pass File's Owner when Nib file is loaded.
     [[NSBundle mainBundle] loadNibNamed:@"YourNibFileName" owner: option:];
  B) Load viw UIViewController
     [[UIViewController alloc] initWithNibName:@"YourNibFileName" bundle:[NSBundle mainBundle]
     In this way, File's Owner Object is set to "self" (the instance of UIViewController)

Referenct:
  1) Resource Programming Guide
     http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html#//apple_ref/doc/uid/10000051i-CH1-SW1)

阅读(1431) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~