关闭文档而不退出应用程序时 Lion 恢复
我第一次把脚浸入可可中。
这是一个简单的问题。 OS X Lion 支持在应用程序终止并重新启动时恢复窗口状态。好的,很好。
但对于基于文档的应用程序,相同恢复功能是否还可以在文档关闭并稍后重新打开时管理窗口状态的保存但无需退出应用程序?(在换句话说,无论应用程序是否退出,它是否都可以持续管理每个文件的状态?或者我是否必须通过将信息保存在文档文件中来管理它?)
例如,iWork '09 应用程序做< /em> 做这种事事情:如果您关闭已保存的文档并重新打开它,它将恢复窗口大小、位置和滚动条位置。我不知道它是否使用 Lion's Resume 本身来做到这一点。
但是,相比之下,OS X Lion 的 TextEdit 在退出并重新启动时会恢复窗口,但它不会记住关闭文档并重新打开时的窗口状态。这让我怀疑,在不退出的情况下使用 Resume 可能无法自动实现(因为 Pages 可能以其专有文件格式保留窗口状态,但 TextEdit 不会,因为它使用纯文本、RTF、HTML 等文件)。
我还没有访问 WWDC 2011 视频,OS X 发行说明、OS X 应用程序编程指南和 NSWindowRestoration API 文档都没有专门讨论这一点。
那么问题又来了:关闭并重新打开文档窗口后自动记住文档窗口的状态,无需退出应用程序(就像 iWork 一样)...Lion's Restore 支持此功能吗?
多谢!
I'm dipping my feet into Cocoa for the first time.
Here's a simple question. OS X Lion supports Resuming of window state when an app is terminated and relaunched. Okay, good and fine.
But for document-based apps, can the same Resume feature also manage saving of window state when a document is closed and reopened later but without any quitting of the app? (In other words, can it manage each file's state persistently regardless of whether the app quits or not? Or do I have to manage it myself by saving the information in the documents' files?)
For instance, iWork '09 apps do do this sort of thing: if you close a saved document and reopen it, it will restore the window size, location, and scroller position. I don't know if it does this using Lion's Resume per se.
But, in contrast, OS X Lion's TextEdit restores windows when it is quit and restarted, but it does not remember window states when you close a document and reopen it. This makes me suspicious that using Resume without quitting might not be possible automatically (since maybe Pages keeps window states in its proprietary file format, but TextEdit doesn't since it uses plain text, RTF, HTML, etc. files).
I don't have access to the WWDC 2011 videos yet, and neither the OS X release notes, the OS X Application Programming Guide, nor the NSWindowRestoration API docs talk about this specifically.
So the question again: automatically remembering the state of a document window after closing and reopening it without quitting the app (like iWork does)...does Lion's Restore support this?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是没有帮助,不是。
或者其他地方,是的。
我未经测试的建议是尝试自己使用窗口恢复协议。关闭时,向自己发送
encodeRestorableStateWithCoder:
,然后将该数据存储在文档中(或任何您想要的位置)。打开文档时,如果它具有可恢复的状态信息,请将其传递给restoreStateWithCoder:
。Not unassisted, no.
Or somewhere else, yes.
My untested suggestion is to try using the window-restoration protocol yourself. When closing, send yourself
encodeRestorableStateWithCoder:
, then stash that data in your document (or wherever you want). When opening a document, if it has restorable state information, pass it torestoreStateWithCoder:
.