1

在这篇文章的底部,我包含了一个包含我的代码的示例项目。我有一个使用主默认窗口的 Cocoa 应用程序,以及我创建的另一个窗口 nib。当程序启动时,我希望它加载窗口笔尖并将其显示在默认的“MainMenu”笔尖窗口前面。我怎样才能做到这一点?我试过下面的代码,但窗口仍然显示在默认窗口后面:

InfoWindowController *winInfo = [InfoWindowController new];

[winInfo.window makeKeyAndOrderFront:self];
[winInfo.window setOrderedIndex:0];
[winInfo.window makeKeyAndOrderFront:self];
[winInfo showWindow:self];

这是从 调用的AppController,这是我添加到 MainMenu 笔尖的一个类。InfoWindowController 子类NSWindowController。我在这里包含了一个示例项目

4

1 回答 1

3

So, I know i'm reviving an old thread, but I was having a similar issue. Try putting [NSApp activateIgnoringOtherApps:YES]; in there.

于 2011-05-13T03:37:32.287 回答