1

NSWindow のサイズを特定のサイズに変更しようとしています:

NSRect frame = [_window frame];

frame.size.width = 1024;
frame.size.height = 768 + 42; // add 42 for window frame

[_window setFrame: frame display: YES];
[_window center];

調整された高さは常に Mac OS X アプリケーション ドックでクリップされるため、私の場合、ウィンドウ内のビューの高さは 768 ではなく 680 になります。ドックを超えて強制的にサイズ変更する方法はありますか?

4

1 に答える 1

2

Fixed it by implementing a subclass to override constrainFrameRect:toScreen:

- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
    return frameRect;
}

From the Mac Developer Library, NSWindow Class Reference, constrainFrameRect:toScreen:

If the window is resizable and the window’s height is greater than the screen height, the rectangle’s height is adjusted to fit within the screen as well. The rectangle’s width and horizontal location are unaffected. You shouldn’t need to invoke this method yourself; it’s invoked automatically (and the modified frame is used to locate and set the size of the window) whenever a titled NSWindow object is placed onscreen and whenever its size is changed. Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.

于 2013-06-24T13:55:12.787 に答える