gpt4 book ai didi

ios - 我什么时候应该使用 didFinishLaunchingWithOptions?

转载 作者:行者123 更新时间:2023-11-28 18:23:14 25 4
gpt4 key购买 nike

我觉得我应该知道这一点,但我不知道,这总是让我感到困惑。

浏览示例代码和教程时,我有时会看到 AppDelegates 有一个

@property UIWindow* 窗口,

然后是 @synthesized 然后是一个

[窗口 setRootViewController:controllerToBeSet]

[窗口 makeKeyAndVisible]

其他应用在委托(delegate)中的任何地方都不会有一行代码。

我知道 Storyboard中友好的箭头表示 Root View Controller 。那么打包的 AppDelegates 是否仅适用于基于 nib 的项目?

我需要清楚地了解使用 didFinishLaunchingWithOptions 委托(delegate)方法的规范以及最初设置 View 的方式。

最佳答案

你的理解基本正确。以下引用来自 Apple 的文档(在“在您的应用程序中使用 View Controller ”):

The Main Storyboard Initializes Your App’s User Interface

The main storyboard is defined in the app’s Information property list file. If a main storyboard is declared in this file, then when your app launches, iOS performs the following steps:

It instantiates a window for you. It loads the main storyboard and instantiates its initial view controller. It assigns the new view controller to the window’s rootViewController property and then makes the window visible on the screen.

如果不使用 Storyboard,则需要实例化窗口,设置窗口的 Root View Controller ,并在 didFinishLaunchingWithOptions 方法中使窗口可见。如果您在关闭 Storyboard的情况下启动单 View 项目,则可以从模板中获取它。

关于ios - 我什么时候应该使用 didFinishLaunchingWithOptions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16534532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com