2 つの異なる xib に対応する 2 つの NSWindowControllers を持つ NSDocument サブクラスがあります。
Document-Based Application Guide に従って、document.m 実装に以下を追加しました。
- (void)makeWindowControllers
{
NSLog(@"in MakeWindowControllers");
MainWindowController *mainWindowController = [[MainWindowController alloc] init];
[mainWindowController autorelease];
[self addWindowController:mainWindowController];
csvWindowController = [[CSVWindowController alloc] init];
[csvWindowController autorelease];
[self addWindowController:csvWindowController];
}
問題は、2 番目のウィンドウ コントローラー csvWindowController で最初にそのウィンドウを非表示にすることです。後でウィンドウの同じインスタンスを表示します。そうするために私は書いた:
@implementation CSVWindowController
- (id) init {
if ( ! (self = [super initWithWindowNibName:@"CSVWindow"]) ) {
NSLog(@"CSVWindowController init failed");
return nil;
}
window = [self window];
NSLog(@"CSVWindowController init");
[window orderOut:nil]; // to hide it
NSLog(@"CSVWindowController hiding the window");
return self;
}
しかし、ウィンドウはそこにあり、現れています。
VisibleAtLaunch にフラグが立てられていないこと、コンソールにメッセージが正しく表示されていること、および変更しても次のことをしないでください。
[window orderOut:nil]; // to hide it
to
[window orderOut:self]; // to hide it
結果は同じで、ウィンドウが表示されます。
どんな助けでも大歓迎です、ありがとう:)