在UITextView中插入图片
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:self.textView.attributedText];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil] ;
NSString *str = [[NSBundle mainBundle] pathForResource:@"001" ofType:@"png"];
UIImage *img = [UIImage imageWithContentsOfFile:str];
textAttachment.image = img;
NSAttributedString *textAttachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment] ;
[string insertAttributedString:textAttachmentString atIndex:self.textView.text.length];//index为用户指定要插入图片在文本框中的位置,从0开始
self.textView.attributedText = string;