2013년 7월 11일 목요일

AppDelegate에서 NSView 추가하기

1. 메인 윈도우의 사이징과 같이 사이징되는 NSView


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSView *superview = [self.window contentView];

    mainView = [[MainView alloc] initWithFrame:[superview frame]];
    [superview addSubview:mainView];
    [superview setAutoresizesSubviews:YES];
    [mainView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
    [mainView release];
}

2. 고정 크기를 가지는 NSView


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSView *superview = [self.window contentView];

    mainView = [[MainView allocinitWithFrame:[NSMakeRect(0,0,100,100]];
    [superview addSubview:mainView];
    [mainView release];
}

* mainView는 NSView에서 상속받아 만든 클래스이다.

3. 해제

- (void)applicationWillTerminate:(NSNotification *)notification
{
    [super dealloc];

}

댓글 없음:

댓글 쓰기