UITextView 和 NSUndoManager 同步
我尝试先搜索,但找不到我需要的东西。
我有一个 UITextView,并且有在 UITextViews NSUndoManager 上执行撤消和重做操作的按钮,因此该部分可以正常工作,但问题来了。撤消操作正在撤消我在文本视图成为第一响应者后创建的所有更改,因此能够进行详细的撤消或重做操作,这些操作仅撤消或重做最后一个操作,而不是从 UITextView 成为第一响应者那一刻起执行的所有操作应该有这样的代码:
- (void)textViewDidChange:(UITextView *)textView
{
[textView resignFirstResponder];
[textView becomeFirstResponder];
}
但这段代码不是一个解决方案,它可以工作,但我想以与上面的代码相同的方式同步在 UITextView 中执行的操作,但不放弃 UITextView 作为第一响应者。
Tnx寻求帮助。
I have tried to search first but couldn't find exactly what I need.
I have one UITextView and I have buttons that are executing actions undo and redo on UITextViews NSUndoManager so that part is working but here comes the problem. Undo actions are undoing all changes that I create after text view becomes first responder, so to be able to have detailed undo or redo actions that are undoing or redoing only the last action and not all actions performed from the moment where UITextView become first responder I should have code like this:
- (void)textViewDidChange:(UITextView *)textView
{
[textView resignFirstResponder];
[textView becomeFirstResponder];
}
But this code is not a solution, it works but I would like to synchronize actions performed in UITextView in the same way like the code above but without resigning UITextView as the first responder.
Tnx for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我没记错的话,每个撤消/重做操作都按事件循环分组。如果您在同一个事件循环中执行许多操作,则所有这些操作都会形成相同的操作。
If im not wrong, each undo/redo action is grouped by an event loop. If yo do many thing within the same event loop, all those things form the same action.