开发者

Using a xib file without initializing a view controller

开发者 https://www.devze.com 2023-01-27 01:35 出处:网络
I\'d like to use IB to create a toolbar with assorted toolbar items, but create and use this toolbar programatically - adding it to a view at my 开发者_JS百科discretion, and not while initializing the

I'd like to use IB to create a toolbar with assorted toolbar items, but create and use this toolbar programatically - adding it to a view at my 开发者_JS百科discretion, and not while initializing the view controller.

I'm pretty sure it can be done - but haven't been able to find a good reference. Any help?


Read about NSBundle's loadNibNamed:owner:options: method:

NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"Toolbar" owner:self options:nil];

This will return all the objects in nib which you can get using simple array methods. Also note that if nib file references any outlets to other objects in nib - they must be defined in your controller (or any other given nib owner) as well otherwise you'll get KVC exceptions.

0

精彩评论

暂无评论...
验证码 换一张
取 消