2012-05-21 2 views
0

내 프로그램의 .xib에서 경계선없는 윈도우를로드하려고합니다. 나는 다음과 같이 [[[NSWindow]] initWithContentRect:styleMask:backing:defer:]를 재정 의하여와 경계선 창을로드 할 수 [self orderFront:self]; 포함 된 다른 메소드가 호출보기가있는 xib에서 경계선없는 윈도우로드

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { 

    self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag]; 
    if (!self) { 
     return nil; 
    } 

    [self setOpaque:NO]; 
    [self setHasShadow:YES]; 
    [self setLevel:NSFloatingWindowLevel]; 
    [self setBackgroundColor:[NSColor clearColor]]; 
    [self setAlphaValue:1.0]; 

    // Ignore events 
    [self setIgnoresMouseEvents:YES]; 

    return self;  
} 

, 창을 보여줍니다. 그러나이 메서드를 호출 할 때 표시 할 창을 만든 별도의 .xib 파일이 있습니다. 파일의 소유자가 NSApplication으로 설정되어 있고 창 자체는 앞서 언급 한 코드가 포함 된 클래스입니다. 어떻게하면 [self orderFront:self];으로 메서드를 호출 할 때 xib에 창을로드하고 창을 만드는 대신이 클래스를 표시 할 수 있습니까?

답변

2

내가하는 일을 이해했다면 NSWindowController을 사용하여 별도의 펜촉 (또는 xib) 파일에서 NSWindow을로드 할 수 있습니다. 서브 클래스 NSWindowController를 열고 컨트롤러 코드를 입력하십시오. xib 파일에 해당 객체를 만들고 파일의 소유자로 설정합니다. NSWindow를 NSWindowController의 델리게이트 콘센트에 연결하십시오.

은 그럼처럼 쉽게 : 당신의 도움에 대한

NSWindowController * windowController = [[[YourWindowClass alloc] initWithWindowNibName:@"YourWindowClass"] autorelease]; 
NSWindow * sheet = [windowController window]; 
+0

덕분에 -이 내가,이 코드 예제 프로젝트 도움이하고 싶었던 정확히되지 동안! – rick