2014-01-11 7 views
0

화면에 그리려하고 있지만 작동하지 않습니다. 나는 약간의 연결이없는 것 같아. 가장 큰 문제는 백만 개 및 하나의 iOS 자습서를 찾았지만 Mac OSX는 없다는 것입니다. 매우 실망합니다. 스크린 샷은 내가 NSView의의 서브 클래스라는 MyQuartzView을 만들어 엑스 코드 5OSX 용 Quartz2D는 아무 것도 그리지 않습니다

Created a custom view

를 사용하고 있는데 ... 나는 내 프로젝트가 설정 한 방법을 보여줍니다. 다음은 MyQuartzView.m에있는 목록입니다.

#import "MyQuartzView.h" 

@implementation MyQuartzView 

- (id)initWithFrame:(NSRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 

    } 
    return self; 
} 

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

    // Drawing code here. 
    CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort]; 
    NSLog(@"%@", myContext); 
    CGContextSetRGBFillColor (myContext, 1, 0, 0, 1); 
    CGContextFillRect (myContext, CGRectMake (0, 0, 200, 100)); 
    CGContextSetRGBFillColor (myContext, 0, 0, 1, .5); 
    CGContextFillRect (myContext, CGRectMake (0, 0, 100, 200)); 
} 

@end 

MyQuartzView.h에는 코드가 없습니다.

내가 막혔습니다 ... 도와주세요! 미리 감사드립니다!

답변

1

고맙습니다. 알아 냈습니다. Xcode의 인터페이스 부분에있는 "Identity Inspector"를 통해 내 창으로 드래그 한 내 사용자 정의보기를 MyQuartzView 클래스에 연결하는 것을 잊었습니다.

관련 문제