如何使NSWindow到前面和当前空间? [英] How to bring NSWindow to front and to the current Space?
本文介绍了如何使NSWindow到前面和当前空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这段代码来打开我的窗口:
I'm using this code to bring up my window:
[self.window makeKeyAndOrderFront:self];
[self.window setOrderedIndex:0];
但通常它会在其他窗口之下或在其他Space桌面上显示,我最后打开它。如何让它总是出现在用户的前面?
But often it will be beneath other windows or displayed in other Space desktop that I last open it in. How do I make it always appear "in front" to the user?
更新
我找到了以前提出问题的答案;使窗口显示在其他窗口的顶部:
[NSApp activateIgnoringOtherApps:YES];
Update I found the answer from previously asked question; make the window show up to the top of other windows: [NSApp activateIgnoringOtherApps:YES];
但是如何将应用程序移动到用户的当前空间?
But how to move the app to the user's current Space?
推荐答案
将您的应用推向前面:
[NSApp activateIgnoringOtherApps:YES];
Swift:
NSApp.activateIgnoringOtherApps(true)
这篇关于如何使NSWindow到前面和当前空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文