简体   繁体   中英

Is applicationWillEnterForeground always called after applicationDidEnterBackground?

I am trying to figure out some logic in my iOS application delegate. I want to perform some actions in applicationDidEnterBackground and undo them in applicationWillEnterForeground, as suggested. But I want to make sure that, unless the app is terminated, applicationWillEnterForeground is always called after applicationDidEnterBackground. I know that this is generally the case, but I know that there are always fringe cases (authorizations, other interruptions like phone calls, notifications). I think that I have checked most cases and found that applicationWillEnterForeground will always be called to counter applicationDidEnterBackground but I want to see if there are any cases that I am missing where this is not the case.

Set a Boolean value in the user defaults when you enter the background. Then, when you re-enter the foreground check the value of that Boolean to determine whether or not it was set properly. Either way, always set the Boolean to false when returning to the foreground.

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