简体   繁体   中英

How to change iOS view displayed when app reactivates from background.

I have a root view controller that opens up a new modal view controller. When the app goes to the background I dismiss the top view but when the app opens up again, there is a split second that I see the view I just have dismissed and then the root view displays.

How can I prevent the top view from showing up when the app becomes active again.

I have tried to dismiss the top view on all the stages I could think on the app delegate (applicationWillResignActive, applicationDidEnterBackground, applicationWillEnterForeground, applicationDidBecomeActive) as well on viewWillDisappear on the top view itself without success. The view does dismiss but I can see it for a split second when the app becomes active.

Can someone help me to show the root view all the time when the application becomes active? I don't want to do anything with the launch image, that is working fine. I just don't want the app to show other views but the root view after launching/ becoming active. If that is not possible then can I show an image till the root view controller is ready to be displayed?

Thanks.

At the end of applicationDidEnterBackground , the OS will take a picture of your UI. Apple tell us this in the documentation :

When the applicationDidEnterBackground: method returns, the system takes a picture of your app's user interface and uses the resulting image for transition animations. If any views in your interface contain sensitive information, you should hide or modify those views before the applicationDidEnterBackground: method returns.

But I bet you are dismissing your modal view controller animated in that, so when it takes the picture it will be taking the picture just as the view is being animated away. You could try dismissing it not animated. It might then mean that during the transition to the background the user sees the root view controller, but I think you're just going to have to live with one of those options unfortunately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM