In my application I am presenting a modal view controller on top of the root view controller on launch and also when resuming from the background to present a loading/summary screen. This is dismissed after a few seconds to reveal the root view controller. The modal is presented via the applicationWillEnterForeground
method on the app delegate.
It's all working fine, but when resuming from the background it's quite common to see a flash of the lower root view controller before the loading modal is presented again.
I'm struggling to find an obvious way to do this presentation to ensure it safely appears without seeing the view underneath first. Am I missing something blindingly obvious?
The documentation says the following:
This means you should modify the view in
applicationDidEnterBackground:
to have it the way you want it to appear in the picture that iOS will take automatically when an App enters the background state.Also keep the following in mind:
As I recall, when an app is backgrounds Apple code takes a screenshot and stores it off. When your app is brought back up it displays the screenshot until your app finishes coming up and takes over.
Short answer, I don't think it's possible to avoid the flash of the content.
You really have 2 choices, I would just suggest making a short "appear" animation to make a smooth transition. That wont work if you are trying to protect sensitive material with a relogin prompt or something though. If you are dealing with a situation like that you need to handle things when you enter backound state and not when you ae coming back from it.