使用NSWindowController工作加载NIB文件但是当窗口加载时它显示并立即隐藏。发生什么事?我不知道。这是我的代码:
- (IBAction)loadMyWindow:(id)sender
{
NSWindowController * windowController;
if (windowController == nil) {
windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
[windowController window];
}
}
有人有想法吗?
答案 0 :(得分:2)
在使用ARC的项目中,我们必须在方法windowController
loadMyWindow
NSWindowController *windowController; //for example here
- (IBAction)loadMyWindow:(id)sender
{
if (windowController == nil) {
windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
[windowController window];
}
}
答案 1 :(得分:0)
只需添加第[windowController showWindow:self]
行