我认为问题是你正在测试模拟器。在设备上,它应该可以正常工作。
我测试了这个并且它有效。当应用程序进入后台时,添加带有启动图像的图像视图 -
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.window.bounds];
imageView.tag = 101; // Give some decent tagvalue or keep a reference of imageView in self
// imageView.backgroundColor = [UIColor redColor];
[imageView setImage:[UIImage imageNamed:@"Default.png"]]; // assuming Default.png is your splash image's name
[UIApplication.sharedApplication.keyWindow.subviews.lastObject addSubview:imageView];
}
当应用程序返回前台时 -
- (void)applicationWillEnterForeground:(UIApplication *)application
{
UIImageView *imageView = (UIImageView *)[UIApplication.sharedApplication.keyWindow.subviews.lastObject viewWithTag:101]; // search by the same tag value
[imageView removeFromSuperview];
}
注意 - 在模拟器(iOS 7.0)上,当您按两次主页按钮(Cmd + H)进行检查时,添加的子视图不会显示,但在设备上它会按预期工作(例如paypal
, BofA
apps)
编辑:(附加信息)
除了如上所述通过添加子视图/模糊来模糊/替换敏感信息之外,iOS 7使您能够通过以下方式忽略屏幕快照ignoreSnapshotOnNextApplicationLaunch
of UIApplication
inside applicationWillResignActive
or applicationDidEnterBackground
.
UIApplication.h
// Indicate the application should not use the snapshot on next launch, even if there is a valid state restoration archive.
// This should only be called from methods invoked from State Preservation, else it is ignored.
- (void)ignoreSnapshotOnNextApplicationLaunch NS_AVAILABLE_IOS(7_0);
Also, allowScreenShot
可以探索标志限制负载.