如何防止在应用程序启动osx时显示窗口 [英] How to prevent displaying window on application startup osx

查看:78
本文介绍了如何防止在应用程序启动osx时显示窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习OS X的Objective-C和编程应用程序.我想给自己写一个简单的通知程序,应该以这种方式工作:

I am learning Objective-C and programming applications for OS X. I want to write myself a simple notifier, which should work this way:

  • 连接到网站并检查是否有新内容(我已经覆盖了内容)
  • 显示带有诸如忽略",访问网站"之类的操作按钮的窗口(这也很容易)

我想,我会将我的应用添加到启动中,如果网站上没有任何更改,则只需终止它即可.但是,如果有新内容,带有操作按钮的窗口将在应用程序检查之前弹出,并且窗口将快速闪烁.我该如何预防?

I thought, that I will add my app to startup and if there are no changes on the website - just terminate it. But the window with action buttons will pop up before application checks, if there is a new content and window will flash quickly. How do I prevent that?

是否有更好的方法来创建这样的东西?例如,不是在启动过程中运行我的应用程序-运行守护进程,而是每24小时检查一次网站,然后显示一个窗口?我该怎么办?

Is there a better way to create something like this? For example instead of running my application during startup - running a daemon, that will check the website every 24 hours and then display the window? How can I do that?

最近,我阅读了立即开始开发Mac Apps ,所以我可能仍然缺少明显的东西.

Recently, I read Start Developing Mac Apps Today, so I might be still missing something obvious.

推荐答案

选择NSWindow,然后在启动时关闭可见".

Select NSWindow and just turn off Visible At Launch.

如果要显示该窗口,请按以下步骤手动进行操作.

If you want to show the window, do it manually as follows.

- (void)applicationWillFinishLaunching:(NSNotification *)notification {
    /* Do whatever necessary before the window appears */
    [window setIsVisible:YES];
}

我个人从来没有打开启动时可见"开关.

Personally, I never have the Visible-At-Launch switch on.

这篇关于如何防止在应用程序启动osx时显示窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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