简体   繁体   中英

viewDidAppear called after applicationDidEnterBackground?

As far as I know nothing can be called after applicationDidEnterBackground returns since after that the app gets suspended. My app is designed in such a way - it start with the initial controller which loads some data from the server and once it is loaded it segues to another controller. I set a break point to viewWill/DidAppear of my second vc and another breakpoint to applicationDidEnterBackground in AppDelegate. The I start the app and immediately minimised it. To my big surprise applicationDidEnterBackground was not the last breakpoint that I was able to catch! Sometimes I was catching them in this order SecondVC.viewWillAppear -> applicationDidEnterBackground -> SecondVC.viewDidAppear and sometimes in this applicationDidEnterBackground -> SecondVC.viewWillAppear -> SecondVC.viewDidAppear ! How is this possible ? The only adequate explanation that I can figure out is that when the app is attached to debugger lifecycle works slightly different but I'm not sure that this is the reason. So, can somebody explain why this happens? Thank you!

applicationDidEnterBackground: is not the last routine that is executed by the app process before it gets suspended.

According to the description of this method, your app process is not suspended for about the next 5 (five) seconds after this method is called, and keeps running normally.

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