None of the other solutions worked for me, so I ended up using an NSWindow
as the sheet controller (rather than a NSViewController
on its own).
Declare an NSWindowController
object in your header file:
NSWindowController *detailWindow;
To open the window in the form of a sheet, use the following code:
NSStoryboard *storyFile = [NSStoryboard storyboardWithName:@"Main" bundle:nil];
detailWindow = [storyFile instantiateInitialController];
[self.view.window beginSheet:detailWindow.window completionHandler:nil];
To close the window:
[self.view.window endSheet:detailWindow.window];
In order to stop the window sheet from being resized, simply set the NSWindow
minimum/maximum size in interface builder:
That's it, super easy! (Don't forget to set the window controller, as the initial controller).