本文档:Preventing Sensitive Information From Appearing In The Task Switcher描述了一种在 applicationDidEnterBackground 中显示视图控制器的方法,以便在任务切换器中隐藏关键信息:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Your application can present a full screen modal view controller to
// cover its contents when it moves into the background. If your
// application requires a password unlock when it retuns to the
// foreground, present your lock screen or authentication view controller here.
UIViewController *blankViewController = [UIViewController new];
blankViewController.view.backgroundColor = [UIColor blackColor];
// Pass NO for the animated parameter. Any animation will not complete
// before the snapshot is taken.
[self.window.rootViewController presentViewController:blankViewController animated:NO completion:NULL];
}
然而,在 iOS 8 中,这个确切的代码不起作用,并且非常简单、普通的黑色视图控制器直到应用程序再次激活后才会显示。任务切换器显示敏感信息,没有任何隐藏。这段代码中没有动画,所以我无法理解 - 为什么会这样?