Is there a way to delay the screen capture made by iOS when app is entering background? The reason is that I'm sometimes showing a view when the user goes to home screen I want this view removed so it doesn't show when app is resumed. The view in question is a SSHUDView (source code here) which I call dismissAnimated:NO in applicationWillResignActive. This actually works in the simulator but not on real device (the SSHUDView still shows when resuming). Anyone have a clue how to deal with this?
I think you should handle this in applicationDidEnterBackground:.
According to Apple's documentation:
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.If you have a look at the SSHUDView implementation it uses a UIWindow instance to display the content; it makes it's own UIWindow the key UIWindow:
[_hudWindow makeKeyAndVisible];
Which is probably why it's so tricky to get rid of. You might try to do what SSHUDView does after it dismisses itself to return focus to the main window:
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] makeKeyWindow];
When the hud view dismissed itself it sends resignKeyWindow to it's private _hudWindow object, you could possibly try to get a handle on that before you return focus to the main window, like so:
[[[[UIApplication sharedApplication] windows] objectAtIndex:1] resignKeyWindow];
But it may cause unexpected problems because you're bypassing the SSHUDView API...
Could you possibly get the view controller displaying the SSHUDView to listen for UIApplicationWillResignActiveNotification from [NSNotificationCenter defaultCenter] and hide it that way? Seems a little hacky, so it may not work. Just a thought.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With