Cocoa:在用X关闭它之后以编程方式显示主窗口 [英] Cocoa: programmatically show the main window after closing it with X

查看:185
本文介绍了Cocoa:在用X关闭它之后以编程方式显示主窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式重新打开我的Cocoa应用程序的主窗口,当用户用X按钮关闭它。
我知道它仍然在内存中,但我不知道在哪里。

I want to programmatically re-open the main window of my Cocoa application after the user closed it with the X button. I know it's still somewhere in memory but I don't know where.

推荐答案

如果你使用默认Cocoa应用程序模板,您的应用程序委托具有对MainMenu.xib中的窗口的引用。你可以简单地调用

If you're using the default Cocoa Application template, your app delegate has a reference to the window that's in MainMenu.xib. You can simply call

[window makeKeyAndOrderFront:self];

可能在菜单触发的 IBAction 项目,重新打开窗口。注意:请确保在IB中取消选中关闭时释放和一次性复选框。

perhaps in an IBAction triggered by a menu item, to reopen the window. Note: be sure that the "Release when closed" and "One shot" boxes are unchecked in IB.

这篇关于Cocoa:在用X关闭它之后以编程方式显示主窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆