Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 当我在NSTextAttachment中拖动图像时,它是一个.rtf文件_Objective C_Cocoa_Nstextfield_Nstextattachment - Fatal编程技术网

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
文件是什么样子的,里面有数据吗?您需要特定的代码来正确处理图像的拖动操作。其中根本没有数据。