2012-07-31 5 views

답변

1

xib에서보기를로드하려면 가장 쉬운 방법은 NSViewController을 사용하는 것입니다. 당신은 프로그래밍 방식 (사용자 정의) 뷰를 만들려면

- (IBAction)showMyAmazingView:(id)sender 
{ 
    NSViewController* myViewController = [[NSViewController] alloc] initWithNibName:@"MyAmazingView" bundle:nil]; 

    NSView* myAmazingView = myViewController.view; 

    // Do whatever you want with myAmazingView 
} 

먼저 초기화해야합니다

- (IBAction)showMyAmazingView:(id)sender 
{ 
    MyAmazingViewSubclass* myAmazingView = [[MyAmazingViewSubclass] alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; 

    // Do whatever you want with myAmazingView 
} 

을보기가 다른보기 (수퍼)를 표시에 배치 할 필요가로드 된 후 . 창문의 클라이언트보기에 대한 예를 들어 :

[window.clientView addSubview:myAmazingView]; 

또한 당신은 -setFrame: 방법보기를 배치 할 수 있습니다.