Prevent iOS from taking screen capture of app before going into background
You are on the right track. This is Apple's recommended way to do this as noted in the iOS Application Programming Guide:
Remove sensitive information from views before moving to the background. When an application transitions to the background, the system takes a snapshot of the application’s main window, which it then presents briefly when transitioning your application back to the foreground. Before returning from your
applicationDidEnterBackground:
method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.
Need to write the code in Application life cycle methods, here we are putting an imageView
while the app animate to background :
-(void)applicationWillResignActive:(UIApplication *)application
{
imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];
[imageView setImage:[UIImage imageNamed:@"Splash_Screen.png"]];
[self.window addSubview:imageView];
}
Here is the code to remove the imageView
:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if(imageView != nil) {
[imageView removeFromSuperview];
imageView = nil;
}
}
It is working and properly tested.