为什么 NSWindow 不恢复其状态(使用 Lion 中的 Resume)?

发布于 2024-12-22 12:47:48 字数 1091 浏览 2 评论 0原文

我正在努力在我以前的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姜生凉生 2024-12-29 12:47:49

上面链接的内容 简历文档忽略提及的是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文