大佬教程收集整理的这篇文章主要介绍了UITextView撤消管理器不适用于替换属性字符串(iOS 6),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在UITextView中,我可以撤消任何字体更改,但无法撤消视图的属性字符串副本中的替换.使用此代码时……
- (void) replace: (NSAttributedString*) old with: (NSAttributedString*) new { 1. [[myView.undoManager prepareWithInvocationTarget:self] replace:new with:old]; 2. old=new; }
…撤消工作正常.
但是如果我添加一行来在我的视图中看到结果,则undoManager不会触发“replace:with:”方法,因为它应该……
- (void) replace: (NSAttributedString*) old with: (NSAttributedString*) new { 1. [[myView.undoManager prepareWithInvocationTarget:self] replace:new with:old]; 2. old=new; 3. myView.attributedText=[[NSAttributedString alloc] initWithAttributedString:old]; }
- (void)applyAttributesToSELEction:(NSDictionary*)attributes { UITextView *textView = self.contentCell.textView; NSRange SELEctedRange = textView.SELEctedRange; UITextRange *SELEctedTextRange = textView.SELEctedTextRange; NSAttributedString *SELEctedText = [textView.textStorage attributedSubStringFromRange:SELEctedRange]; [textView.undoManager beginUndoGrouping]; [textView replaceRange:SELEctedTextRange withText:SELEctedText.String]; [textView.textStorage addAttributes:attributes range:SELEctedRange]; [textView.undoManager endUndoGrouping]; [textView setTypingAttributes:attributes]; }
以上是大佬教程为你收集整理的UITextView撤消管理器不适用于替换属性字符串(iOS 6)全部内容,希望文章能够帮你解决UITextView撤消管理器不适用于替换属性字符串(iOS 6)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。