Search code examples
macoscocoaxcode5xib

Loading xib from button press


I have a project that requires to load another xib file when a user press a button

In the main page of my project there are 6 buttons each is link to another xib (NSViewController)

Main Page

When a user presses on a button it will show a nib file

About EPiC Online

Here's what I've done

-(IBAction)About:(id)sender {
    self.aboutViewController = [[AboutViewController alloc]initWithNibName:@"AboutViewController" bundle:nil];
    self.aboutViewController.view.frame = ((NSView*)self.window.contentView).bounds;
}

is this correct?


Solution

  • Please see my comment above but at a pure guess, I don't see [self.window.contentView addSubview:self.aboutViewController.view] being called anywhere, so if your problem is that you're not seeing the view, that's at least one sure reason why.