When my app goes to the background, it has to blur the current screen for data protection reasons. The content of the screen must not be seen in the task manager window, so the blurring routine has to be done before the app quits. As every UI update, the blurring must take place on the main loop. It simply adds a blurred view over the normal main view. However, this takes a little time to finish, and that's the problem.
I call my blurring routine from applicationWillResignActive: as Apple recommends. Now let's say it takes 0.2 seconds to finish the task. If the app will be reactivated within this short period of time, applicationDidBecomeActive: isn't called (which should unblur my screen again, so it's left blurred).
Maybe you think that it's not normal user behavior to "close" and "open" an app in such a short period of time, but think about tapping the upper edge of the screen and moving down a bit, just by accident while trying to tap a button that's at the upper edge. This will activate the Notification Center for just some fractions of a second. That's enough.
Just for making this problem transparent, have a look at this AppDelegate that will post the unbalanced calls in the console:
@implementation UHAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"applicationWillResignActive - performing some tasks...");
// let the main loop do some work...
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.2]];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
@end
Any ideas how to achieve a balanced number of calls to applicationWillResignActive: and applicationDidBecomeActive: in this case...?
Thx a lot for your help Udo