首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从另一个NSAlert的didEndSelector调用NSAlert

从另一个NSAlert的didEndSelector调用NSAlert
EN

Stack Overflow用户
提问于 2009-10-10 05:11:03
回答 2查看 1.8K关注 0票数 2

我需要根据来自另一个NSAlert的响应调出一个NSAlert。但是,当我尝试从第一个didEndSelector调用它时,发生了各种糟糕的事情(比如我的文档窗口消失了,以及关于打印到控制台的排序问题的警告)。

有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-10-10 06:03:18

你要做的就是“链接”警报。

为此,您需要在警报窗口上调用orderOut:

以下是文档:

如果要在模式委托执行响应返回值的操作之前从alertDidEndSelector方法中清除工作表,请将orderOut:(NSWindow)发送到通过将window发送到alert参数而获得的window对象。这允许您链接工作表,例如,在alertDidEndSelector方法中显示下一张工作表之前先清除一张工作表。请注意,在调用alertDidEndSelector方法之前,应注意不要从程序中的其他位置调用orderOut:。

票数 5
EN

Stack Overflow用户

发布于 2009-10-11 04:04:42

有一种更简单的方法,只需在if语句中检查[runModal]的内容:

代码语言:javascript
复制
//setup the dialog
NSAlert *networkErrorDialog = [NSAlert alertWithMessageText:@"Couldn't connect to the server" defaultButton:@"Network Diagnostics" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:@"Check that your computer is connected to the internet and make sure you aren't using a proxy server or parental controls"];

//show the dialog inside an IF, 0=the first button 1=the 2nd button etc
                if ([networkErrorDialog runModal]==0) {
                    //quit
                    [[NSApplication sharedApplication] terminate:self];
                } else {
                    //Network Diagnostics
                    [[NSWorkspace sharedWorkspace] launchApplication:@"Network Diagnostics"];
                    [[NSApplication sharedApplication] terminate:self];
                }

希望这能有所帮助

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1547112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档