本文介绍了Xcode-当应用程序处于活动状态时(从后台返回)显示ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序从后台出现时,我想显示一个特定的ViewController.

I want to show a specific ViewController when the app comes foregrounded from the background.

我正在使用此方法来调用ViewController.

I am using this method to call a ViewController.

- (void)applicationWillEnterForeground:(UIApplication *)application
{
  [self presentMyViewController];
}

但是从后台返回时会有延迟.换句话说,您可以看到上一个视图,然后看到ViewController.我根本不想显示以前的视图.

But there is a delay when it comes back from the background. Or in other words, you can see the previous view, then you see the ViewController. I don't want to show the previous view at all.

如何实现呢?

推荐答案

在应用程序后台运行之前,在您的应用程序委托的applicationDidEnterBackground:方法中隐藏旧视图.实际上,这是Apple出于隐私原因特别推荐的一种机制此处:

Hide the old view before the app is backgrounded, in your app delegate's applicationDidEnterBackground: method. This is in fact a mechanism that Apple specifically recommends for privacy reasons here:

这篇关于Xcode-当应用程序处于活动状态时(从后台返回)显示ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:10