【问题标题】:Why won't an NSWindow restore its state (using Resume in Lion)?为什么 NSWindow 不能恢复其状态(在 Lion 中使用 Resume)?
【发布时间】:2011-12-22 16:00:49
【问题描述】:

我正在努力在我以前的 Snow Leopard 应用中实施 Resume。对于我的应用程序的主窗口,我检查了 Interface Builder 中的 Restorable 复选框,一切正常。它的代表有 -window:willEncodeRestorableState:state-window:didDecodeRestorableState: 调用它,很好。一切正常。

我有另一个窗口,有时在用户退出时也会打开。我检查了Restorable,并实现了上面的两种方法。 ..willEncode.. 当我在窗口打开的情况下退出时被调用,但 ..didDecode.. 永远不会被调用,并且窗口不会被恢复。我已经阅读了documentation,似乎我可能想要创建一个恢复类,但文档并没有特别清楚地说明如何去做。

我尝试在我的 AppDelegate 和我的第二个可恢复窗口的委托中实现 <NSWindowRestoration> 协议,但从未为它们中的任何一个调用过 +restoreWindowWithIdentifier:state:completionHandler: 方法。

我错过了什么?我在NSWindowRestoration 的正确轨道上,但做得不对吗?文档谈论恢复类的方式,听起来好像只有一个。我需要在应用程序的 plist 中指定它吗?

【问题讨论】:

    标签: objective-c cocoa osx-lion nswindow resume


    【解决方案1】:

    上面链接的Resume documentation 忽略的是NSWindow-restorationClass 属性。如果您在代码中设置此属性(设置为实现<NSWindowRestoration> 的类,则该类负责创建窗口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-03
      • 2011-09-04
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多