我的 RootViewController 的 viewDidLoad 被 application:didFinishLaunchingWithOptions: 和 applicationDidBecomeActive: 调用
我正在使用带有 UINavigationController
的 Storyboard,该 UINavigationController 设置为“初始视图控制器”。它附加了 RootViewControllers。 viewDidLoad
方法在 application:didFinishLaunchingWithOptions:
和 applicationDidBecomeActive:
之后调用。
为什么会发生这种情况?
I am using a Storyboard with a UINavigationController
that is set as "is initial View Controller". It's attached RootViewControllers. viewDidLoad
method gets called after application:didFinishLaunchingWithOptions:
and applicationDidBecomeActive:
.
Why does that happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为视图是在应用程序激活之前加载的。活动被定义为应用程序开始响应事件的点,您需要一个视图来实现这一点。
Because the view is loaded before your application becomes active. Active is defined as the point at which your application begins responding to events, and you need a view for this.
如果您想知道为什么在这些方法之后调用
viewDidLoad
方法,我建议您阅读 应用程序启动序列-ios。这是每个 iOS 应用程序中正常的引导执行。当您实例化具有关联视图的控制器时,该控制器的视图需要一些时间才能加载到内存中。
viewDidLoad
不会立即调用,而是仅在视图完全加载时调用。在这里,您可以确保该视图的出口已正确链接。希望有帮助。
If you want to know why
viewDidLoad
method gets called after those methed I suggest you to read the app-launch-sequence-ios. It's the normal bootstrap execeution in every iOS application.When you istantiate a controller with an associated view, the view for that controller takes some time to load in memory.
viewDidLoad
is not called immediately but only when the view has been loaded completely. Here you are sure that outlet for that view are linked correctly.Hope it helps.