我有一個NSDocument子類與兩個NSWindowControllers對應於2個不同的xib。NSWindowController不在init中隱藏其窗口?
繼基於文檔的應用指南我已經加入我的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];
}
問題是,我想第二個窗口控制器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
結果顯示出來一樣,窗口。
任何幫助表示讚賞,感謝:)