문제

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

도움이 되었습니까?

해결책

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

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