如何使用Obj-C轻松保存窗口大小和位置状态? [英] How can I easily save the Window size and position state using Obj-C?

查看:92
本文介绍了如何使用Obj-C轻松保存窗口大小和位置状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Obj-C记住应用程序加载之间Windows位置的最佳方法是什么?我正在为接口使用Interface Builder,是否可以通过绑定来做到这一点.

What is the best way to remember the Windows position between application loads using Obj-C? I am using Interface Builder for the interface, is it possible to do this with bindings.

推荐的方法是什么?谢谢.

What is the recommended method? Thank you.

推荐答案

在界面生成器"的属性"下的自动保存"字段中,为该窗口输入一个唯一的名称(例如"MainWindow"或"PrefsWindow").然后它将自动将其位置保存在用户默认设置"中.

Put a name that is unique to that window (e.g. "MainWindow" or "PrefsWindow") in the Autosave field under Attributes in Interface Builder. It will then have its location saved in your User Defaults automatically.

要以编程方式设置自动保存名称,请使用-setFrameAutosaveName:.如果您有基于文档的应用程序,或者在IB中设置自动保存名称没有意义的其他情况,则可能需要这样做.

To set the Autosave name programmatically, use -setFrameAutosaveName:. You may want to do this if you have a document-based App or some other situation where it doesn't make sense to set the Autosave name in IB.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆