親愛なるすべて、 NSOutline Viewとの対戦で、最後の2〜3日でテーブル内のドラッグアンドドロップを実行していますが、間違っていることを得ることができませんでした。 これはNSOutlineビュードラッグアンドドロップ問題
要件 -1 - 私は透明であるか、またはいくつかの背景イメージを使用したいNSoutlineViewのdrawRectメソッドを上書きする必要があることを私のビューでNSoutlineview、これは何ですか?私は、ヘッダファイル内
@interface MyCustomOutlineView:NSOutlineView{
NSImage *pBackgroundImage;
}
- setBackgroundImage:(NSImage *)pImage;
を行っていますソースファイルで
、私はちょうど背景画像を描画するためのdrawRectといくつかの他のstuffsを上書きしたり、それを透明にし、これが正常に動作している、私の見解では今
、私はそのようなNSOutlineViewオブジェクトを宣言している、
/* *私のカスタムビューは、メソッド、 このメト以下の実装、ソースファイルでグラデーションを描画する機能や他の影響
*/
@interface OutlineParentView:MyCustomView<NSOutlineDataSource>{
MyCustomOutlineView *pOutlineView;
}
@property(nonatomic,retain)MyCustomOutlineView *pOutlineView;
を持っていますDは、ドラッグ&ドロップし、私はリンゴのDragnDropサンプルコードをチェックし
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteb oard:(NSPasteboard *)pboard{
[self log:@"write Items"];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:items];
[pboard declareTypes:[NSArray arrayWithObject:OutlineViewPrivateDataType]
owner:self];
[pboard setData:data forType:OutlineViewPrivateDataType];
return YES;
}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
{
NSLog(@"validate Drop");
return NSDragOperationEvery;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index{
[self log:@"inside accept drop for NSView "];
return YES;
}
以下のように実装を関連initWIthFrame
#define OutlineViewPrivateDataType "MyOutlinePrivateData"
-(void)InitOutlineView{
NSRect scrollFrame = [self bounds];
NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame:scrollFrame] autorelease];
[scrollView setBorderType:NSNoBorder];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:NO];
[scrollView setAutohidesScrollers:YES];
[scrollView setDrawsBackground: NO];
NSRect clipViewBounds = [[scrollView contentView] bounds];
pOutlineView = [[[CommUICustomOutlineView alloc] initWithFrame:clipViewBounds] autorelease];
NSTableColumn* firstColumn = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease];
ImageTextCell *pCell = [[ImageTextCell alloc]init];
[firstColumn setDataCell:pCell];
[pCell setDataDelegate:self];
[firstColumn setWidth:25];
[pOutlineView addTableColumn:firstColumn];
[pOutlineView setRowHeight:30];
[pOutlineView setDataSource:self];
/* setData delegate implemented in the MyOutlineView to handle some of event in this
interface if i don't write this, then i can't handle the menu event on the
Outlineview
*/
[pOutlineView setDataDelegate:self];
**/* On this line i am getting one warning, saying OutlineParentView doesn't implement
NSOutlineView delegate protocol */**
[pOutlineView setDelegate:self];
[scrollView setDocumentView:pOutlineView];
/* I don't want group row to be highlighted */
[pOutlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[pOutlineView registerForDraggedTypes:
[NSArray arrayWithObjects:OutlineViewPrivateDataType,nil]];
[pOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[self addSubview:scrollView];
[self setAutoresizesSubviews:YES];
[self log:@"Outline view created "];
}
その他の重要なメソッドから呼び出されますが、私はやっているものを手に入れることができませんでした、間違った私は信じ 、
といくつかの問題[pOutlineView setDelegate:自己]
機能が、どのようにそれを解決するために、私ドンという「Tは、私は、最近、私は、カスタムテーブルビューにドラッグ&nDropを実行することができた、MyTableViewからMyOutlineViewに最近アップグレード 残りのものは...データソースなどのように、アドバンス 種類で
感謝を正常に動作され、 を知っていますよろしく ローハン