关于NSoutlineView和WriteItem |拖放问题 [英] Regarding NSoutlineView and WriteItem | Drag-and-Drop Problem

查看:173
本文介绍了关于NSoutlineView和WriteItem |拖放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要处理拖放"操作,请完成以下操作

To handle Drag-n-Drop have done following,

-(void)InitMyOutlineView{
 - - - - -  - - - - - - - -  -- - - - - - - -  -
 - - - - - - - - - - - - - -- -- - - - - - - - - 
[pMyOutlineView registerForDraggedTypes:
     [NSArray arrayWithObject:NSStringPboardType]];

/* I tried both Yes and No */   
[pMyOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
- - - -  -- - - - - - -- - - - - - - -- - - - - - 
- -- -- - - - - -- - - - - - - - - - -  - -- - - - 
}

如下所示的WriteItem方法,

The WriteItem method as below,

- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard{
    [self log:@"write Items"];
    NSString *pStr = [NSString stringWithFormat:@"this is the temp string "];
       [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
       [pboard setString:pStr forType:NSStringPboardType];
       [self log:@"returning YES"];
       return YES;
}

现在我希望控件将进入AcceptDrop方法,但断点没有到达该位置,并且在Log/gdb中获取以下日志

Now i am expecting control will come to AcceptDrop method, but break point didn't hit there, and in the Log/gdb getting following log

2011-02-04 16:21:25.435 MyApp[2006:a0f] write Items
2011-02-04 16:21:25.437 MyApp[2006:a0f] returning YES
2011-02-04 16:21:25.439 MyApp[2006:a0f] *** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at objects[0]

并且控件没有接受acceptDrop方法,

and control didn't come to acceptDrop method,

当我启用"Stop on Exception"时,以下是它停止时的调用堆栈,

When i enable "Stop on Exception" following is the call stack when it stopped,

#0  0x981b94e6 in objc_exception_throw
#1  0x96ed34cf in -[__NSPlaceholderArray initWithObjects:count:]
#2  0x96efaaa3 in +[NSArray arrayWithObject:]
#3  0x92316dfd in -[NSOutlineView _columnsForDragImage]
#4  0x923f1e32 in -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:]
#5  0x91fea16a in -[NSTableView _performDragFromMouseDown:]
#6  0x91fe89b9 in -[NSTableView mouseDown:]
#7  0x91fe864e in -[NSOutlineView mouseDown:]
#8  0x91f86c68 in -[NSWindow sendEvent:]
#9  0x91e9f817 in -[NSApplication sendEvent:]
#10 0x91e332a7 in -[NSApplication run]
#11 0x91e2b2d9 in NSApplicationMain

让我更新另一件事,在我的轮廓视图中,我有自定义单元格,不过我正在使用的Mac ImageTextCell接口文件什么也没有.

Let me update one more thing, in my outline view, i have custom cell, which is nothing but Mac ImageTextCell interface file i am using.

任何人都可以指导我,我做错了什么

Can anyone please guide me, what i am doing wrong

亲切问候 罗汉

推荐答案

[myoutlineView setOutlineColoumn:firstColumn]丢失, 当我添加内容后,其变味的工作

[myoutlineView setOutlineColoumn : firstColumn] was missing, when i added then its tarted working

这篇关于关于NSoutlineView和WriteItem |拖放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆