Xcode-当应用程序处于活动状态时(从后台返回)显示ViewController [英] Xcode - Show a ViewController when the app becomes active (coming back from the background)
问题描述
当应用程序从后台出现时,我想显示一个特定的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:
在移至背景之前,从视图中删除敏感信息.当应用程序过渡到后台时,系统会为应用程序的主窗口拍摄快照,然后在将应用程序过渡回前台时短暂显示该快照.从applicationDidEnterBackground:方法返回之前,您应该隐藏或遮盖可能会在快照中捕获的密码和其他敏感个人信息.
Remove sensitive information from views before moving to the background. When an app transitions to the background, the system takes a snapshot of the app’s main window, which it then presents briefly when transitioning your app back to the foreground. Before returning from your applicationDidEnterBackground: method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.
这篇关于Xcode-当应用程序处于活动状态时(从后台返回)显示ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!