Pregunta

I have a Cocoa app that calls a sheet from the main window. This works fine from an NSButton on the main window. However, when I call from a MainMenu item, the sheet shows as a separate window. Is this expected behavior, or just expected from me :) I have studied this question ..

I call the sheet with this code:

-(IBAction) showSettingsSheet:(id)sender {
    NSLog(@"%s", __FUNCTION__);
    settingsSheetController = [[SettingsSheetController alloc] initWithWindowNibName:@"SettingsSheet"];
    [settingsSheetController beginSheetModalForWindow:self.window completionHandler:^(NSUInteger returnCode) {

        if (returnCode == kSettingsSheetReturnedOk) {
            NSLog(@"Settings Returned ok");

        } else if (returnCode == kSettingsSheetReturnedCancel) {
            NSLog(@"Settings Returned cancel");
        } else {
            //self.categoryDisplayString = @"Oops!";
            NSLog(@" Ooops");
        }

    }];

}

UPDATE

This is how the Attributes Inspector is set:

enter image description here

¿Fue útil?

Solución

Try like this, if you want to display sheet in a mainmenu then try the below steps:-

enter image description here

Uncheck the visible at launch option inside attribute inspector of window which you want to display as a sheet attached the screenshot as well

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