iOS - UITextView + NSUndoManager [英] iOS - UITextView + NSUndoManager

查看:267
本文介绍了iOS - UITextView + NSUndoManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在UITextView(我正在构建一个LateX编辑器)没有运气,并且老实说,我真的很困惑这个论点的整合撤消/重做功能。我不明白这两个操作涉及的步骤,我的意思是我需要两个方法

I'm trying to integrate the undo/redo features in a UITextView (I'm building a LateX editor) with no luck and to be honest I'm really confused about this argument. I don't understand the steps involved in those two operations, I mean I need two methods


  • 一个删除最后插入的文本

  • 一个恢复删除的文本

一个疑问是我得到最后插入的文本?换句话说,我必须注册撤消?

One doubt is where I get the last inserted text? in other words where I have to register for the undo?


  • 在textViewDidChange中我可以得到整个文本

  • 在textViewShouldChangeTextInRange中,

我知道我写的不是最好的解释,但我希望有人在这里曾经遇到过同样的问题并可以给我一个提示。基本上,为了恢复,我必须添加撤消/重做功能到一个textview,可能有两个按钮链接到这些动作。

I know that what I wrote wasn't the best explanation ever, But I hope someone here has faced the same problem in the past and can give me an hint. Basically ,to resume, I have to add the undo/redo features to a textview, possibly having two buttons linked with those actions.

提前感谢

推荐答案

我现在感觉像一个白痴(解决方案真的很容易... textView已经有一个undoManager所以基本上步骤有一个textView的撤销/重做操作是:
在viewDidload内:

I'm feeling like an idiot right now :( the solution was really really easy... The textView has already an undoManager so basically the steps to have undo/redo actions for a textView are : inside viewDidload :

myUndoManager = [textView undoManager];

您要执行操作的位置

[myUndoManager undo]; // or redo

真的哑的有时,我几乎写我自己的撤销代码...我希望这可以帮助某人

I'm really dumb sometimes, I was almost writing my own undo code... I hope this can help someone

这篇关于iOS - UITextView + NSUndoManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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