开发者

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 i开发者_StackOverflowt 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.


You can also use this way: -

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


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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜