문제

I have a problem with a sheet that when opened for the first time, will open unattached to the window. After dismissing it, then the sheet works as it should.

Here is the code that I am starting the sheet with:

- (IBAction)addButtonAction:(id)sender {

    assert ([editorController window]);
    assert (window);

    [NSApp beginSheet: [editorController window]
       modalForWindow: window 
        modalDelegate: editorController 
       didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) 
          contextInfo: nil]; 
}

The variables 'window' and 'editorController' are initialized in the application delegate header file as @private.

The 'didEndSelector' is defined in the 'editorController' code file and is called when the window is closed.

The code for the 'didEndSelector' is as follows:

- (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
    [sheet orderOut:self];
}

The window is cancelled with a call to selector 'cancelButtonAction' which is as follows:

- (IBAction)cancelButtonAction:(id)sender {
    [NSApp endSheet:self.window];
}

Any thoughts would be appreciated.

도움이 되었습니까?

해결책

Make sure the "visible at launch" option on the NSWindow in the xib file isn't turned on.

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