Loading a preview from a nib file in the interface builder

I have my own toolbar view, which I store in my own nib file. I want to use this toolbar in other tips. Can you just look at some kind of preview in the main nib file and load the toolbar into it? Preferably in the interface builder.

thank

+3
source share
2 answers

It looks like you have one view in the nib file, and you want to be able to load an instance of this view in different places of your application.

Here whatcha do:

First, in the nib file, change the File Owner class to UIViewController and configure your custom view as a property of the File Owner view.

, , :

UIViewController *vc = [[UIViewController alloc] initWithNibName:@"YourCustomNib" bundle:nil];
UIView *yourCustomView = vc.view;
[vc release];

, , , "" . , tableview nib.

+2

- , nib? ,

NSArray *arr = [[NSBundle mainBundle] loadNibnamed:@"customToolBarNibName" owner:... options:...];

UIView *rootView = [arr objectAtIndex: 0];
+3

All Articles