Objective c 当我在NSTextAttachment中拖动图像时,它是一个.rtf文件
我有一个Objective c 当我在NSTextAttachment中拖动图像时,它是一个.rtf文件,objective-c,cocoa,nstextfield,nstextattachment,Objective C,Cocoa,Nstextfield,Nstextattachment,我有一个NSTextView,它显示这样的图像 NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; NSImage *attachImage = [NSImage imageNamed:@"Settings"]; attachment.image = attachImage; NSAttributedString *attributedString = [NSAttributedString attributedStr
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文件,而不是一个图像。无论如何,关于这个问题?这个
.rtf
文件是什么样子的,里面有数据吗?您需要特定的代码来正确处理图像的拖动操作。其中根本没有数据。