Pregunta

Loading NIB file using NSWindowController work but when window did loaded it showing and immediately hide. What happen? I don't know. Here is my code:

- (IBAction)loadMyWindow:(id)sender
{
    NSWindowController * windowController;

    if (windowController == nil) {
        windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
       [windowController window];
    }
}

Anybody have an idea?

¿Fue útil?

Solución

In project with ARC we must announce a variable windowController outside the method loadMyWindow

NSWindowController *windowController; //for example here

- (IBAction)loadMyWindow:(id)sender
{
    if (windowController == nil) {
        windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
       [windowController window];
    }
}

Otros consejos

Just add the line [windowController showWindow:self]

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top