强制viewDidLoad在iOS上触发 [英] Force viewDidLoad to fire on iOS
问题描述
我有两个窗口应用程序,当我出现第一个窗口时,我希望第二个窗口中的视图加载并为后面的后台准备内容。
I have two window app and while I present first window I would like the view in second window to load and prepare content for later in background.
我是尝试使用方法 loadView
但是Apple说你不应该直接调用这个方法。
I've tried to use method loadView
but Apple says you should not call this method directly.
到目前为止我选择了使用视图的方法 userInteractionEnabled
实际上隐含
调用 viewDidLoad
方法。
So far I've chosen to use the view's method userInteractionEnabled
which actually implicitly
calls viewDidLoad
method.
是否有一种优雅的方法可以强制 ViewControllers
viewDidLoad
方法在它应该自然之前开火(当窗口是键并显示时)?
Is there an elegant way to force ViewControllers
viewDidLoad
method to fire before it should naturally (when window is key and presented)?
推荐答案
您只需调用 [viewController view];
。
UIViewController的文档解释了视图属性是如何延迟加载的,以及 viewDidLoad
是否被调用视图加载后编辑。
The documentation for UIViewController explains how the view property is lazy-loaded and that viewDidLoad
is called after the view is loaded.
这篇关于强制viewDidLoad在iOS上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!