基于文档的应用程序中的 NSUndoManager 错误行为
在我的基于文档的应用程序中,我为 [self undoManager] 调用prepareWithInitationTarget 和registerUndoWithTarget。但是,在“编辑”菜单中,“撤消”和“取消”重做仍然是空白。我可以通过调用 [[self undoManager] undo] 手动执行撤消,并且它可以工作。
为了确保安全,我创建了一个新项目,在其中调用了prepareWithInitationTarget 和registerUndoWithTarget。魔法!现在可以单击编辑菜单中的撤消/重做元素。
造成这种情况的可能原因是什么?我尝试检查界面生成器中的连接,但它们与我创建的新项目中的连接相同。知道如何修复它吗?
In my document based app I call prepareWithInvocationTarget and registerUndoWithTarget for [self undoManager]. However, in Edit menu, Undo & Redo are still blank. I can execute undo manually by calling [[self undoManager] undo] and it works.
Just to make sure, I created a new project, called in it prepareWithInvocationTarget and registerUndoWithTarget. Magic! Undo/Redo elements in Edit menu could be clicked now.
What could be a possible reason for this? I tried checking connections in interface builder but they are the same as in the new project I created. Any idea how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我已经解决了。
问题是我有一个基于文档的项目,在我的文档委托中我调用了 [self undoManager]。我应该在主窗口上调用它。我已将其更改为 [mProjectWindow undoManager] (因为 mProjectWindow 指向文档的主窗口),现在一切正常。
Ok, I've got it worked out.
The issue was that I had a document based project and in my document delegate I callsed [self undoManager]. I was supposed to call it on the main window instead. I've chcanged it to [mProjectWindow undoManager] (because mProjectWindow points to the main window of the document) and now eveyrthing works fine.