如何在 applicationWillFinishLaunching 委托中终止可可应用程序
在用户开始使用我的应用程序之前,我必须向他们显示自定义许可协议对话框。因此,我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我自己找到了解决方案。这是我的错误,我需要调用 [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.