简体   繁体   English

NSOutlineView的拖放方法没有被调用

[英]Drag and Drop methods for NSOutlineView are not getting called

I'm trying to enable drag&drop for NSOutlineView in my OSX app. 我正在尝试在我的OSX应用程序中为NSOutlineView启用拖放功能。 The only thing I need to be able to drop is png image from the Finder. 我唯一能够放弃的是来自Finder的png图像。

I have myOutlineView and a controller which is a data source and a delegate of my outline view. 我有myOutlineView和一个控制器,它是一个数据源和我的大纲视图的委托。

In my outline view controller I have these three methods: 在我的大纲视图控制器中,我有以下三种方法:

-(BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard

 -(NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index

-(BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index{

none of them is being called...my nib is setup properly...my outline view is getting filled and all of the functionality is working except the drag&drop feature... 没有人被调用...我的笔尖设置正确...我的大纲视图已经填满,所有功能都在工作,除了拖放功能...

Any kind of help is highly appreciated! 任何形式的帮助都非常感谢!

Just fixed it I placed 刚刚修好我放了

[[self currentOutlineView] registerForDraggedTypes:[NSArray arrayWithObjects:(NSString*)kUTTypeFileURL,kPrivateDragUTI,nil]];

to the wrong spot, so my outline view couldn't register the draggable types appropriately. 到了错误的位置,所以我的大纲视图无法正确注册可拖动的类型。 I placed it to 我把它放到了

-(void) awakeFromNib 

in my outline view controller and everything is working now! 在我的大纲视图控制器,一切正常! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM