我正在尝试将撤消和重做功能添加到我的UITextView
. 我正在使用attributedText
而不是简单地text
使用UITextView
. 我尝试使用Apple 文档undoManager
中引用的函数调用,但似乎没有任何反应。我很惊讶我在谷歌上找不到任何关于这个主题的东西。之前有没有人遇到过这个问题/在with上实现了撤消和重做/知道如何解决这个问题?UITextView
attributedText
示例代码
textView.attributedText = NSMutableAttributedString(string: "SOME TEXT")
@objc func undo(_ sender: UIButton) {
textView.undoManager?.undo()
}
@objc func redo(_ sender: UIButton) {
textView.undoManager?.redo()
}