您是否可以强制加载NSWindow,即是否在屏幕上显示它之前? [英] Can you force a NSWindow to load, i.e. before it is presented onscreen?

查看:121
本文介绍了您是否可以强制加载NSWindow,即是否在屏幕上显示它之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只支持在需要时才对对象进行延迟实例化,尤其是对于像NSWindows这样的繁重对象而言.不幸的是,尽管我使用的是WebKit视图,并且需要一种方法来预加载页面(最多可能需要10秒钟),所以我想在应用启动后立即开始视图层次结构的初始化.我正在构建任务栏应用程序,因此启动时看不到任何窗口.

I am all in favor of lazy instantiation of objects only once they are needed, especially with heavy ones like NSWindows. Unfortunately though I am using a WebKit view and need a way to preload a page (which can take up to 10) seconds, so I would like to kick off the view hierarchy initialization as soon as the app launches. I am building a task bar application so no windows are visible at startup.

我的第一个直觉是快速的隐藏和显示",但是必须有一种更好的方法来强制窗口取消存档本身并调用其awakeFromNibwindowDidLoad方法?

My first instinct is a quick "hide and show" but there must be a better way to force a window to unarchive itself and call its awakeFromNib and windowDidLoad methods?

推荐答案

如果您使用NSWindowController管理窗口,则可以调用窗口控制器的-window方法以使其加载窗口而不显示它.像这样:

If you're using an NSWindowController to manage the window, you can call the window controller's -window method to cause it to load the window without showing it. Like so:

// Window is not loaded
[windowController window];
// Window is now loaded but not on screen
[windowController showWindow:nil];
// Window is now visible

这篇关于您是否可以强制加载NSWindow,即是否在屏幕上显示它之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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