开发者

Retaining an NSWindow size and state - looking for an elegant way to do this

开发者 https://www.devze.com 2023-01-11 05:39 出处:网络
I have a controller class which spawns a window when a certain condition occurs. This window can be closed by the user, moved around or resiz开发者_高级运维ed.

I have a controller class which spawns a window when a certain condition occurs. This window can be closed by the user, moved around or resiz开发者_高级运维ed.

Ideally, when this condition occurs, I'd like the window to re-open in the same spot the user closed it last time.

Looking for an elegant way to do this. Pointers (or references) will be most welcome.


Luckily, AppKit knows this is a common pattern and has provided -setFrameAutosaveName:, which does this automatically for you. (If you're using NSWindowController you'll want to call setShouldCascadeWindows:NO, which will override this.)

0

精彩评论

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