Kyle
Kyle

Reputation: 21

How to load .nib into view?

I made this program in Java and now I'm porting it over to a Mac App and when it opens I have a nib open that displays instructions, and when the user clicks "Next" I want it to open my second view and close the first one. I made the second nib complete with everything, but I just don't know how to load it or from where.

I understand Objective-C code relatively well, but when it comes to using Interface Builder and making guis I get confused.

Upvotes: 2

Views: 3384

Answers (3)

Michal Zaborowski
Michal Zaborowski

Reputation: 5099

I have created library which allow you to load custom view from nib, all you need to do is set File's Owner to Class File. Check it here: https://github.com/inspace-io/INSNibLoading

Upvotes: 0

Omar Freewan
Omar Freewan

Reputation: 2678

You can also use this way: -

 [[NSBundle mainBundle] loadNibNamed:@"MyXibFileName" owner:self];

Upvotes: 5

AliSoftware
AliSoftware

Reputation: 32681

Simply use NSBundle's Additions and + (BOOL)loadNibNamed:(NSString *)aNibName owner:(id)owner:

[NSBundle loadNibNamed:@"YourOtherNib" owner:self];

By using "self" as the owner, everything connected to the "File's Owner" in your NIB file will be connected to self's IBOutlets

Note: You can find more information about NIB file in Apple's documentation that should help you understanding how NIB files work.

Upvotes: 2

Related Questions