从另一个视图控制器加载视图控制器时显示启动屏幕
我有一个应用程序,它以启动画面 (Default.png) 打开,然后在导航控制器中加载第一个视图 (ViewController1
)。立即创建 ViewController2
(VC2) 的实例,并将其推送到导航控制器上:
[self.navigationController pushViewController:VC2 animated:NO];
因此,当我运行应用程序时,会显示默认图像,然后显示 ViewController1
的视图code> 会短暂显示,直到加载(然后显示)ViewController2
。
如何停止 ViewController1
的短暂显示?我可以延长 Default.png 的显示直到 VC2 显示,或者用 Default.png 图像覆盖 ViewController1
直到 VC2 显示吗?
非常感谢。
I have an app that opens with a splash screen (Default.png), then loads the first view (ViewController1
) in a navigation controller. Straight away, an instance of ViewController2
(VC2) is created, and pushed onto the navigation controller:
[self.navigationController pushViewController:VC2 animated:NO];
So when I run the app, the default image is displayed, then the view of ViewController1
is briefly displayed until ViewController2
is loaded (and then displayed).
How can I stop the brief display of ViewController1
? Can I extend the display of Default.png until VC2 is displayed, or cover ViewController1
with the Default.png image until VC2 shows?
Thanks so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您只想显示 VC2 而不显示 VC1,则在 VC1 的
viewDidLoad
方法中,您可以执行self.view.hidden = YES;
然后推送没有动画的VC2If the only thing you want to do is to show VC2 without showing VC1, in the
viewDidLoad
method of your VC1 you can doself.view.hidden = YES;
then push the VC2 without animation我认为在您的情况下,您希望 VC2 作为您的起点,而 VC1 作为您的临时启动屏幕。 default.png 图像应该是一种反映应用程序外观的方式,以给人留下应用程序启动和运行速度比看起来更快的印象。 (这取自Apple 的 HIG)
您可能需要考虑将 VC1 设为您的新版本启动画面/加载屏幕。您可以将其制作成一个简单的等待或加载页面,然后在处理完应用程序中的所有内容后加载 VC2。 Default.png 可以是加载屏幕的图像,并且会给人您的应用程序正在立即加载的印象。
对于如何处理这个问题有很多不同的意见。您最终必须决定哪种方法最适合您和您的应用程序。
最后一个想法是,您可以直接加载到 VC2 并仅显示加载进度视图。我使用 MBProgressHUD 在我加载信息或执行用户需要等待的任务时将用户锁定。这可能是另一种选择。希望这些信息有帮助。
I think in your case, you want VC2 to be your starting point with VC1 as your ad-hoc splash screen. The default.png images should be a way to mirror the look of your app to give the impression your app is starting and working faster than it may appear. (This is taken from Apple's HIG)
You may want to consider making VC1 your new splashscreen/loading screen. You could make it into a simple waiting or loading page then load VC2 once everything in your app has been taken care of. Default.png could be an image of the loading screen and would give the impression your app is loading right away.
There are many differing opinions of how to approach this issue. You will ultimately have to decide which method is best for you and your application.
One final thought, you could load directly to VC2 and just present a loading progress view. I have used MBProgressHUD to lock the user out while I load information or perform tasks they need to wait for. This could be another option. Hope this information helps.
您可以使用 Default.png 将
UIImageView
添加到 VC1,然后在viewDidDisappear:
中将其删除。You can add a
UIImageView
to VC1 with Default.png, then remove it inviewDidDisappear:
.我认为您无法修改 Default.png 行为。我建议您在 ViewController1 中创建一个 UIImageView,并使用 Default.png 作为其图像。为其指定与屏幕完全相同的大小,并将其添加为完全覆盖屏幕的子视图。这样你就会看到 Deafult.png 两次,然后它就会转到 ViewController2
I don't think you can modify the Default.png behaviour. I would suggest you create an UIImageView in ViewController1 with Default.png as its image. Give it the exact same size as the screen and add it as a subview that completetely covers it. That way you will see Deafult.png twice and after it will go to ViewController2