gpt4 book ai didi

cocoa - 允许特定数量的 NSWindow 副本可见

转载 作者:行者123 更新时间:2023-12-03 17:44:45 24 4
gpt4 key购买 nike

我的应用程序中有一个按钮,当您单击它时,它会打开一个新的 NSWindow。但是,如果您继续单击它,它将打开另一个 NSWindow。如何限制可见窗口的数量?

最佳答案

禁用该按钮。如果您有一个创建新窗口的按钮,那么它应该创建一个新窗口。如果您不希望用户创建新窗口,请不要让他们单击该按钮。

编辑如果您正在处理诸如首选项窗口之类的内容,那么您可能应该使用 NSWindowController 子类来控制该窗口。单击该按钮基本上应该执行以下操作(preferencesWindowController 是一个 ivar):

- (void) showPreferences:(id)sender {
if (preferencesWindowController == nil) {
preferencesWindowController = [[PreferencesWindowController alloc] init];
}
[preferencesWindowController showWindow:sender];
}

关于cocoa - 允许特定数量的 NSWindow 副本可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3220140/

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