试图让它工作,但不确定我错过了什么。这个想法是将图像放在 a 上NSTableView,以便我可以抓住它们的路径并为它们做一些操作。我可以让 drop 工作NSPastebouardTypeString,但我一辈子都不能让它注册从 Finder 拖动 PNG 到 tableview 中。我错过了什么?
相关代码:
- (void)awakeFromNib {
[imageTableView registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypePNG]];
}
- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation {
NSLog(@"Validate Drop");
return NSDragOperationEvery;
}
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id < NSDraggingInfo >)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation {
NSLog(@"Accept Drop");
return YES;
}