viewController的viewdidload在appDelegate的方法之前调用 [英] viewController's viewdidload called before appDelegate's method

查看:87
本文介绍了viewController的viewdidload在appDelegate的方法之前调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的viewDidLoad调用之前初始化一些代码,但它总是首先转到viewDidLoad然后转到方法applicationDidFinishLaunching。
我无法理解发生了什么?

I want to initialize some code before my viewDidLoad called , but it always go to viewDidLoad first and then it comes to the method applicationDidFinishLaunching. I am unable to understand what is going on?

推荐答案

application:didFinishLaunchingWithOptions

您应该使用此方法初始化您的应用程序并准备
它以便运行。在您的应用程序启动
并且其主nib文件已加载后调用它。当此方法被
调用时,您的应用程序处于非活动状态。在
之后的某个时刻,此方法返回,调用后续委托方法将您的应用程序
移动到活动(前景)状态或后台
状态。

You should use this method to initialize your application and prepare it for running. It is called after your application has been launched and its main nib file has been loaded. At the time this method is called, your application is in the inactive state. At some point after this method returns, a subsequent delegate method is called to move your application to the active (foreground) state or the background state.

因此,一旦调用了view属性或方法,就会为视图控制器延迟加载视图。当发生这种情况时,会调用viewDidLoad,因此如果您的窗口rootViewController属性设置为nib中的根ViewController,那么这是预期的行为。

So the view is lazily loaded for view controllers once the the view property or method is called. When this happens viewDidLoad is called so if your window rootViewController property is set to your root ViewController in the nib then this is expected behavior.

这篇关于viewController的viewdidload在appDelegate的方法之前调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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