2014-09-13 5 views
0

간단한 드래그 앤 드롭 앱을 만들고 확인하는 동안 드래그 작업이 등록되지 않습니다. MainMenu.xib에 NSView를 놓은 다음 해당 NSView를 서브 클래 싱했습니다.코코아 드래그 앤 드롭 등록 안함

DropView.h

#import "DropView.h" 

@implementation DropView 

- (id)initWithFrame:(NSRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     [self registerForDraggedTypes: [NSImage imagePasteboardTypes]]; 
    } 
return self; 
} 

- (NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender{ 
if ([NSImage canInitWithPasteboard:[sender draggingPasteboard]] && [sender draggingSourceOperationMask] & NSDragOperationCopy) { 
    return NSDragOperationCopy; 
} 
return NSDragOperationNone; 
} 

- (NSDragOperation) draggingUpdated:(id<NSDraggingInfo>)sender{ 
    NSLog(@"DRAGGING!"); 
    return NSDragOperationCopy; 
} 

-(void) draggingEnded:(id<NSDraggingInfo>)sender{ 
    NSLog(@"ENDED!"); 
} 

-(void) draggingExited:(id<NSDraggingInfo>)sender{ 
    NSLog(@"EXITED"); 
} 

- (void)drawRect:(NSRect)dirtyRect 
{ 
    [super drawRect:dirtyRect]; 

    // Drawing code here. 
} 

@end 

나는 이것을 실행하고 이미지를 삭제하려고

가, 커서가 +로 변경되지 않는 한 서명

#import <Cocoa/Cocoa.h> 

@interface DropView : NSView <NSDraggingDestination> 
@property (nonatomic, strong) NSImage *image; 
@end 

DropView.m. 메소드가 기록되지 않습니다. 어떤 생각?

답변

0

당신이 당신의 창에 이미지 파일을 드래그하는 경우 다음 당신이 NSFilenamesPboardType 싶은 생각 (?) :

[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];