【发布时间】:2014-02-06 00:16:04
【问题描述】:
我需要将图像从浏览器拖到 mac 应用程序。从img标签拖动图像时,它可以正常工作,但是当img之间有链接时,它就不起作用了。 NSPasteboard 从链接接收 NSURL,而不是从 img 源。拖动反馈显示图像,所以我认为它正在发送图像数据。我从 NSPasteboard 中检查了 propertyListForType,它只包含链接 href。
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
if ([sender draggingSource] == nil){
NSPasteboard *pboard = [sender draggingPasteboard];
if ([[pboard types] containsObject:NSURLPboardType]){
NSURL* file = [NSURL URLFromPasteboard: [sender draggingPasteboard]];
//if <img> tag, file is src. If <a><img></a>, it’s link href
//DOWNLOAD image here
}
}
}
【问题讨论】:
-
你想要 URL 还是只对图片感到满意?
-
如果我有图片我也会很高兴 :) 但我需要知道文件扩展名,而不仅仅是 TIFF 表示
标签: objective-c macos cocoa nspasteboard