开发者

Cocoa How to set max window height but leave width free

I've a window that can be resized in width but has a fixed height, it sounds an easy task but I've an hardcoded value that I really hate.

My code is

NSWindow* w开发者_StackOverflow社区in = ...;
NSSize maxSize = [win maxSize];
maxSize.width = 30000;
[win setMaxSize: maxSize];

How can I write this code to work with a system default?

If my approach is totally wrong how can I set the max window's size for only one dimension (width or height) leaving the other free?


Maybe you could try to implement something like:

- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize {
    proposedFrameSize.height = window.frame.size.height;
    return proposedFrameSize;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜