objective-ccocoanswindowcocoa-sheet

How to show a NSPanel as a sheet


I'm trying to show a NSPanel as a sheet. I'm naively doing something along those lines:

SheetController *sheetController = [[[SheetController alloc]
                                      initWithWindowNibName:@"Sheet"] autorelease];

[[NSApplication sharedApplication] beginSheet:sheetController.window 
                               modalForWindow:self.window
                                modalDelegate:self
                               didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) 
                                  contextInfo:nil];

For some reason that eludes me, this isn't working. When this part of the code is called, the sheet momentarily flashes (because of the autorelease message). The sheet is never hooked to window.

If anyone can point me to where I can find more information, that would be very appreciated.


Solution

  • This sounds like a classic case of having checked the "Visible at Launch" box for the panel in IB. Turn that off.