gpt4 book ai didi

swift - 如何将 NSWindow 置于当前空间的前面?

转载 作者:行者123 更新时间:2023-12-03 16:00:34 25 4
gpt4 key购买 nike

我正在使用此代码来打开我的窗口:

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

但通常它会显示在其他窗口下方或显示在我上次打开它的其他 Space 桌面中。如何使其始终显示在用户的“前面”?

更新我从之前提出的问题中找到了答案;使窗口显示在其他窗口的顶部:[NSApp activateIgnoringOtherApps:YES];

但是如何将应用移动到用户当前的空间呢?

最佳答案

要将您的应用置于最前面:

[NSApp activateIgnoringOtherApps:YES];

swift :

NSApp.activateIgnoringOtherApps(true)

swift 3:

NSApp.activate(ignoringOtherApps: true)

关于swift - 如何将 NSWindow 置于当前空间的前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1740412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com