我有一个_PreferencesWindowController
使用以下实现调用的 NSWindowController 子类 -
@synthesize window;
- (id)init {
self = [super initWithWindowNibName:@"PreferencesWindow"];
if (!self) return nil;
return self;
}
我尝试_PreferencesWindowController
使用以下代码显示窗口 -
_preferencesWindowController = [[_PreferencesWindowController alloc] init];
[_preferencesWindowController showWindow:nil];
它什么也不做,我检查_preferencesWindowController.window
的是nil
调试器。
loadView
但是,如果我调用_preferencesWindowController
窗口可以加载并且是可见的;_preferencesWindowController.window
不再是零值 -
[_preferencesWindowController loadWindow];
我查看了 Apple 在 NSWindowController 上的文档,它明确表示“您永远不应该直接调用loadWindow
”,而showWindow:
应该使用它。我想知道我可能错过了什么导致我看到的上述行为。