如何在 applicationWillFinishLaunching 委托中终止可可应用程序

发布于 2024-09-04 15:27:59 字数 431 浏览 1 评论 0原文

在用户开始使用我的应用程序之前,我必须向他们显示自定义许可协议对话框。因此,我在 mainMenu.xib 中添加了新窗口,并

[NSApp runModalForWindow:licenseWindow];

在 applicationWillFinishLaunching: delegate 中以模态方式使用该窗口显示该窗口,方法是使用可见来隐藏我的主窗口启动至未选中状态。许可证窗口有两个按钮“同意”和“不同意”。如果用户单击“同意”按钮,我需要显示主窗口;如果他们选择“不同意”,我需要终止应用程序。

我尝试调用[NSApp终止];在 applicationWillFinishLaunching: 但它没有做任何事情。

请让我知道如何在 applicationWillFinishLaunching 中终止应用程序:

谢谢

I have to show the custom license Agreement dialog to the user before they start using my application.So, I have added new window in my mainMenu.xib and showing that window modally using

[NSApp runModalForWindow:licenseWindow];

in applicationWillFinishLaunching: delegate by making my main window hidden using visible at Launch to unchecked. License window has two buttons Agree and Disagree. I need to show the mainwindow if user clicks on Agree button and terminate the app if they choose Disagree.

I try to call [NSApp terminate]; in applicationWillFinishLaunching: but it didn't do anything.

Please let me know how I can terminate the app in applicationWillFinishLaunching:

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还在原地等你 2024-09-11 15:27:59

抱歉,我自己找到了解决方案。这是我的错误,我需要调用 [NSApp Terminate:nil];而不是 [NSApp 终止];现在我可以根据需要正常终止我的应用程序。

Sorry I found the solution myself. It was my mistake, I need to call [NSApp terminate:nil]; instead of [NSApp terminate]; and now I am able to terminate my app normally as needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文