Frage

This should be straightforward but I couldn't find anything on either SO or Google on this topic so..

What's the best way of zooming new document windows to full screen (i.e. not the full screen mode but just maximizing the window) for NSDocument based apps?

It might even be some method to override in NSDocument or NSWindowController but I'm unable to locate it. Or are we supposed to do this manually somewhere in the initWithType:error: method..?

War es hilfreich?

Lösung

Use performZoom: to simulate clicking your window's green "Zoom" button.

Your window gets the zoom size from windowWillUseStandardFrame:defaultFrame:. Return a modified NSRect, there, to zoom to a size other than the default zoomed frame.

- (void)windowDidLoad {
    [super windowDidLoad];

    [self.window performZoom:self];
}

- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame {
    // Implement a custom zoomed window size here, or return the default zoomed size.
    return newFrame;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top