Lion 以前的版本可用于恢复,但执行恢复后 UI 绑定未更新
我目前正在开发一个应用程序,并且绞尽脑汁地认为以前的版本无法工作;然而,事实证明,关闭文档窗口并在恢复后重新打开,现在会显示恢复的值。
执行恢复后出现问题,UI 根本不反映恢复已发生。
有谁知道为什么会这样/如何解决这个问题?
谢谢, 克林特
I'm working on an app currently, and was scratching my head thinking that previous versions wasn't working; however it turns out that closing the document window and re-opening after a restore the restored values are now displayed.
The problem arises after performing the restore, the UI simply doesn't reflect that a restore has taken place.
Does anybody know of why this could be / how to fix the issue?
Thanks,
Clint
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否实现了 恢复 Windows UI 状态所需的 API?如果您不知道我在说什么,您需要阅读 文档的此部分。
Have you implemented the required API for restoring the UI state of your windows? If you don't know what I'm talking about, you need to read this section of the documentation.
事实证明,它与 RestoreFromCoder 等无关。
这是每次都会标记文档对象的地方,这不会更新 UI,因为设置属性时会执行 UI 更新,从而导致绑定无效。
我解决这个问题的方法是,每次从文档加载时,它只是将新的文档对象值“同化”到现有的值中(在 init 中初始化为默认值);这会导致用户恢复时 UI 无缝更新。
Turns out, it had nothing to do with the restoreFromCoder etc.
It was where the document object was being stamped over each time, this doesn't update the UI as UI updates a performed when a property is set, thus resulting in the binding being invalidated.
The way I got around this, was by every time it loads from a document, it simply "assimilates" the new document objects values into the existing ones (initialised to defaults in init); this results in the UI updating seamlessly when the user restores.