문제

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?

도움이 되었습니까?

해결책

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];
    }
}

다른 팁

Just add the line [windowController showWindow:self]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top