나는 끌어서 놓기보기에서 작업하고 웹에서 끌어서 놓기 작업을위한 일부 처리기를 발견했습니다. 드래그 앤 드롭 영역에서 파일을 드래그하고 드래그 앤 드롭 영역에서 나가면 다시 회색으로 바뀌므로 파란색으로 변합니다. 마우스 위로 드래그하거나 종료 할 때 업데이트되지 않는 문제가 있습니다. 코드의 Heres는 몇 가지 : 어떤 도움NSView가 업데이트되지 않습니까?
- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
[[NSColor grayColor] set];
[NSBezierPath fillRect:bounds];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
NSRect bounds = [self bounds];
[[NSColor blueColor] set];
[NSBezierPath fillRect:bounds];
return NSDragOperationCopy;
가}
- (void)draggingExited:(id <NSDraggingInfo>)sender {
NSRect bounds = [self bounds];
[[NSColor grayColor] set];
[NSBezierPath fillRect:bounds];
}
감사합니다.
Im는 여전히 코코아에 조금 새로운 것이고, ivar에 대해 듣지 못했습니다. 내가 시도하고 컴파일 할 때 오류가 발생합니다 : 'drawBlueColorIvar'선언하지 않았기 때문에 논리적으로 보이는 (이 함수에서 첫 번째 사용) 선언되지 않았습니다. 나는 어떻게 ivar을 선언합니까? – nosedive25
오, 알았어. 방금 NSColor * drawBlueColorIvar를 추가했다. 뷰 헤더에. 모든 도움에 감사드립니다! – nosedive25