我正在设置拖放代码,我需要知道如何使目标只注册几种类型。一些只是几种图像类型:PNG,JPG,GIF等:以及其他文件夹,图像和视频格式。
我看到了这些粘贴板类型:
Types for Standard Data (Mac OS X 10.6 and later)
The NSPasteboard class uses the following constants to define UTIs for common
pasteboard data types.
NSString *const NSPasteboardTypeString;
NSString *const NSPasteboardTypePDF;
NSString *const NSPasteboardTypeTIFF;
NSString *const NSPasteboardTypePNG;
NSString *const NSPasteboardTypeRTF;
NSString *const NSPasteboardTypeRTFD;
NSString *const NSPasteboardTypeHTML;
NSString *const NSPasteboardTypeTabularText;
NSString *const NSPasteboardTypeFont;
NSString *const NSPasteboardTypeRuler;
NSString *const NSPasteboardTypeColor;
NSString *const NSPasteboardTypeSound;
NSString *const NSPasteboardTypeMultipleTextSelection;
NSString *const NSPasteboardTypeFindPanelSearchOptions;
为什么不是其他人?或者它们与它无关? (通常是混乱的菜鸟)
答案 0 :(得分:0)
假设您已在draggingEntered:
或draggingUpdated:
注册了NSFilenamesPboardType,您可以像这样提取文件名:
NSArray *filenames = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType]
然后检查路径扩展并返回适当的拖动操作。