NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.bounds = rect;
textAttachment.image = image;
NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment];
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithAttributedString:self.contentTV.attributedText];
[attributedText replaceCharactersInRange:_lastSelectedRange withAttributedString:attributedString];
self.contentTV.attributedText = attributedText;
这是我的代码,但是当我插入图片时,textView不会调用委托方法:- (BOOL)textView: shouldChangeTextInRange: replacementText:
和- (void)textViewDidChange:
任何人都可以帮助我吗?感谢。