Cocoa Touch - viewDidLoad 方法的替代方法

发布于 2024-10-10 23:16:21 字数 381 浏览 0 评论 0原文

我正在创建一个从网络读取文本文件的应用程序。当应用程序首次运行时,我希望显示一个带有徽标的启动页面。我有一个 SplashViewController 和一个 MainController。我正在使用教程中的一些代码,该代码允许您向 MainController 的 applicationDidFinishLaunching 方法添加子视图,并用启动屏幕替换主控制器的视图(到目前为止遵循?尽力解释)

我遇到的问题是我想要启动屏幕将一直显示,直到从网络加载数据并为活动指示器设置动画。但是,我正在从 MainController 中的 viewDidLoad 方法中检索数据,并且应用程序在启动画面加载之前开始检索数据,因此在用户看到任何内容之前会有延迟。

在显示启动画面后,是否可以使用另一种方法来开始检索过程?

I am creating an app that reads a text file from the web. WHen the app first runs, I want a splash page to be presented with a logo. I have a SplashViewController and a MainController. I am using some code from a tutorial that allows you to add a subview to the MainController's applicationDidFinishLaunching method and replace the main controller's view with the splash screen (follow so far? Trying my best to explain)

The issue I am having is that I want the splash screen to be present until the data is loaded from the web and animate an activity indicator. However, I am retrieving the data from within the viewDidLoad method in the MainController and the app starts retrieving the data before the splash screen loads so there is a delay before the user sees anything.

Is there another method that I can use to begin the retrieval process after the splash has been displayed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我爱人 2024-10-17 23:16:21

您是否尝试过 -viewDidAppear: 而不是 -viewDidLoad:?前者在视图添加到窗口时发送,而后者在视图加载(从 nib 文件)时发送,即尚未显示。

Have you tried -viewDidAppear: instead of -viewDidLoad:? The former is sent when the view has been added to the window whilst the latter is sent when the view has been loaded (from a nib file), i.e., hasn’t been shown yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文