删除 WebView 的 NSUndoManager 的撤消操作 [英] Removing undo actions for a WebView's NSUndoManager

查看:22
本文介绍了删除 WebView 的 NSUndoManager 的撤消操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个 WebView,可以在我的视图层次结构中换入和换出.其中一些 WebView 包含表单字段,因此我实现了 EditingDelegate 来为我的文档提供 NSUndoManager.

I have several WebViews that I swap in and out of my view hierarchy. Some of these WebViews contain form fields, so I implement the editingDelegate to provide the NSUndoManager for my document.

问题是在 WebView 中完成的任何输入都会生成放置在撤消堆栈上的操作.从层次结构中删除视图后,操作仍在撤消堆栈中.此时,如果用户使用 Cmd-Z 来撤消键入",则会引发异常,因为 -undoEditing: 正在发送到 WebEditorUndoTarget 的释放实例.(WebKit 实现中使用的私有类.)

The problem is that any typing done in the WebView generates actions that are placed on the undo stack. After the view is removed from the hierarchy, the actions are still in the undo stack. At that point, if a user uses Cmd-Z to "Undo Typing", an exception is thrown because -undoEditing: is being sent to a deallocated instance of WebEditorUndoTarget. (A private class used in the WebKit implementation.)

我不能使用 -removeAllActionsWithTarget: 因为我不能引用目标.似乎唯一的解决方案是禁用 WebView 的撤消注册.

I can't use -removeAllActionsWithTarget: because I can't reference the target. It appears the only solution is to disable undo registration for the WebView.

我是否遗漏了什么,或者这是 WebView 的限制?

Am I missing something or is this a limitation of a WebView?

推荐答案

一种私有 API 解决方案是调用 -[WebView _clearUndoRedoOperations].尚未找到公共 API 解决方案.

One private API solution is to invoke -[WebView _clearUndoRedoOperations]. Haven't found a public API solution yet.

这篇关于删除 WebView 的 NSUndoManager 的撤消操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆