从NIB加载时属性为空的问题

来源:互联网 发布:小志网络赚钱博客 编辑:程序博客网 时间:2024/05/22 11:36
// This works completely. All outlets works.PhotoShow* obj = [[PhotoShow alloc] init];[[NSBundle mainBundle] loadNibNamed:@"PhotoShow" owner:obj options:nil];// Outlets are always available at this moment.// This works. but does not connects outlets correctly sometimes.PhooShow* obj = [[PhotoShow alloc] initWithNibName:@"PhotoShow" bundle:[NSBundle mainBundle]];// Outlets may not available at this moment.
NSBundle’s methods are the generic API to use for unarchiving NIBs. They do the actual work (together with NSNib).
UIViewController’s initWithNibName:bundle: on the other hand is a way to initialize a view controller which (might) load its view from a nib. The method does not itself load the nib but just takes note of the name. The controller loads the nib lazily when the view is requested.
0 0
原创粉丝点击