끌어서 놓을 수있는 NSDocuments 리소스가 들어있는 보조 창을 추가하고 싶습니다.문서 기반 응용 프로그램에 보조 창을 추가하는 방법
내 프로젝트에는 다음이 포함
1) ResourceWindow.xib에게
2) ViewController.xib을
3) Main.storyboard
@interface AppDelegate()
@property (nonatomic,strong)NSWindowController* wc;
@property (nonatomic, weak)NSWindow* resourceWindow;
@property (nonatomic, strong)ViewController* vc;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.wc = [[NSWindowController alloc]initWithWindowNibName:@"ResourceController.xib"];
self.resourceWindow = [self.wc window];
[self.wc showWindow:self];
self.vc = [[ViewController alloc]initWithNibName:nil bundle:nil];
[self.vc.view setFrame:[self.resourceWindow.contentView bounds]];
[self.resourceWindow.contentView addSubview:self.vc.view];
}
self.wc.window 즉시 전무하다 그것을 할당하고 초기화 한 후에
나를 바로 설정하십시오.
감사
편집 :
ResourceWindow.xib이 창 컨트롤러를 그냥 창을 포함하지 않습니다. 그게 문제 야? 사용자 정의 객체를 xib 파일로 드래그 앤 드롭하고 클래스를 NSWindowController로 변경하는 솔루션입니까?
ResourceWindow.xib의 파일 소유자는 창에 연결된 창 컨트롤러 여야합니다. 그리고 "ResourceWindow.xib"≠ "ResourceController.xib". – Willeke