为什么 NSWindow 不恢复其状态(使用 Lion 中的 Resume)?
我正在努力在我以前的 Snow Leopard 应用程序中实现 Resume。对于我的应用程序的主窗口,我在 Interface Builder 中选中了“可恢复”复选框,一切正常。它的委托有 -window:willEncodeRestorableState:state
和 -window:didDecodeRestorableState:
调用,很好。一切正常。
我有另一个窗口,当用户退出时有时也会打开。我检查了Restorable
,并实现了上面的两个方法。当我在窗口打开的情况下退出时, ..willEncode..
会被调用,但 ..didDecode..
永远不会被调用,并且窗口不会恢复。我已阅读 文档,看起来我可能想创建一个恢复类,但是文档并没有特别清楚如何做到这一点。
我尝试在我的 AppDelegate 和第二个可恢复窗口的委托中实现
协议,但是 +restoreWindowWithIdentifier:state:completionHandler:
方法从未被调用其中。
我缺少什么?我是否走在正确的轨道上 NSWindowRestoration
但做得不对?从文档谈论恢复类的方式来看,听起来好像只有一个。我需要在应用程序的 plist 中指定它吗?
I'm working on implementing Resume in my formerly Snow Leopard app. For my app's main window, I checked the Restorable
checkbox in Interface Builder, and everything's working fine. Its delegate has -window:willEncodeRestorableState:state
and -window:didDecodeRestorableState:
called on it, just fine. Everything works.
I have another window that is also going to sometimes be open when the user quits. I checked Restorable
for it, and implemented the two methods above. ..willEncode..
gets called when I quit with the window open, but ..didDecode..
never gets called, and the window doesn't get restored. I've read through the documentation and it seemed like I may want to create a restoration class, but the docs weren't particularly clear on how to do so.
I tried implementing the <NSWindowRestoration>
protocol in my AppDelegate, and in my second restorable window's delegate, but the +restoreWindowWithIdentifier:state:completionHandler:
method never got called for either of them.
What am I missing? Am I on the right track with NSWindowRestoration
but not doing it right? The way the docs talked about the restoration class, it sounded like there would only be one. Do I need to specify it in the app's plist or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面链接的内容 简历文档忽略提及的是
NSWindow
的-restorationClass
属性。如果您在代码中设置此属性(为实现
的类,则该类负责创建窗口。What the above linked Resume documentation neglects to mention is
NSWindow
's-restorationClass
property. If you set this property in code (to a class that implements<NSWindowRestoration>
, then that class is responsible for creating the window.