mikmikkelsen
mikmikkelsen

Reputation: 21

How to load and show window from xib file

I have made a window xib and cocoa class file (nswindowcontroller) and need to show the window from xib with an button action from main window.

Upvotes: 1

Views: 1286

Answers (1)

Dev Sanghani
Dev Sanghani

Reputation: 1145

In your main NSWindowController:

In the interface:

@property (nonatomic, strong) CustomWindowController *windowController;

In the implementation:

- (IBAction)didPressOpenWindowButton:(id)sender {
    CustomWindowController *wc = [[CustomWindowController alloc] init];
    [wc showWindow:nil];
    [wc.window makeKeyAndOrderFront:nil];
    _windowController = wc;
}

Connect your IBAction to your NSButton in the main window.

Upvotes: 0

Related Questions