首页 > 解决方案 > 当我在 NSTextAttachment 中拖动图像时,它是一个 .rtf

问题描述

我有一个NSTextView显示这样的图像。

NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
NSImage *attachImage = [NSImage imageNamed:@"Settings"];
attachment.image = attachImage;
NSAttributedString *attributedString = [NSAttributedString  attributedStringWithAttachment: attachment];
[[self.textView textStorage] appendAttributedString:attributedString];

图像显示正确,但我无法将图像从文本字段拖到我的桌面上。每次我尝试时,我最终都会得到一个 .rtf 文件而不是图像。无论如何围绕这个问题?

标签: objective-ccocoanstextfieldnstextattachment

解决方案


推荐阅读