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

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

问题描述

我有几个WebView,它们可以在视图层次结构中切入和切出.其中一些WebView包含表单字段,因此我实现了editDelegate来为我的文档提供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天全站免登陆