How can I replace text in UITextView with NSUndoManager support?

前端 未结 4 555
清歌不尽
清歌不尽 2021-02-06 01:00

I want to be able to replace some text in an UITextView programatically, so I wrote this method as an UITextView category:

- (void) replaceCharactersInRange:(NSR         


        
4条回答
  •  孤街浪徒
    2021-02-06 01:25

    I've been having trouble with this for a long time. I finally realized that you have to make sure you register the undo operation BEFORE doing any changes to your text storage.

提交回复
热议问题