How to know when the user presses the hard button on iOS device before it takes a screenshot of the screen?

StackOverflow https://stackoverflow.com/questions/11616569

Question

On iOS, when the user press the hard button, it seems that the system makes a screenshot of the state of the app (to display it during the next launch of the app, in order to make the loading transparent for the user) and then it calls applicationDidEnterBackground of the UIApplicationDelegate to indicates the apps it went to the background state. Is that right ?

What I need to do is to know that the user pressed the hard button BEFORE the system takes a screenshot. Indeed I'd like to modify my view in case of going to the background state because I want to hide some stuff when the app launch again in the future.

It appears that the applicationDidEnterBackground is callled AFTER the screenshot is taken. Is there a way to be called BEFORE ?

Thanks

Was it helpful?

Solution

- (void)applicationWillResignActive:(UIApplication *)application might run before the screenshot is taken. It is called before - (void)applicationDidEnterBackground:(UIApplication *)application. If it doesn't run before the screenshot, then I don't think you'll be able to change the data for the re-open screenshot without using Private APIs.

OTHER TIPS

You can use the UIApplicationWillResignActiveNotification notification.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top