ios - 进入后台时保护显示数据 : applicationDidEnterBackground

标签 ios iphone

我的应用程序处理敏感数据,我希望用户进入后台后 View 上显示的数据就完全隐藏。我试图通过将一个 View 放在所有其他 View 之上来实现此目的:

[self.window addSubview:self.someShieldView];

我也尝试过,

[self topViewController].view.hidden = YES;

我在 AppDelegate 中这样做

- (void)applicationDidEnterBackground:(UIApplication *)application

按照 iPhoneAppProgrammingGuide.pdf 中的建议第51页

.....When the 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

但我仍然可以看到我的 View 及其数据几秒钟。如何确保我的 View 隐藏在“盾牌”后面?

我关注了这篇文章,但无法实现我想要的。

Delay applicationDidEnterBackground screen capture

我做错了什么?

注意:一种选择是不支持多任务处理,但我确实想支持多任务处理。

最佳答案

在为确切的问题绞尽脑汁一段时间后,我想我可能已经找到了问题所在。

您遇到的问题只发生在模拟器中。在物理设备上(我使用 iphone5s 进行测试)如果您在 applicationDidEnterBackground 中隐藏您的 View ,则临时屏幕截图不会显示隐藏的 View 。

这是我的全部代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window makeKeyAndVisible];
    self.window.backgroundColor = [UIColor redColor]; // this is your secure content
    return YES;
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    self.window.hidden = YES; // this is where you will hide/mask your content
}

关于ios - 进入后台时保护显示数据 : applicationDidEnterBackground,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20672446/

相关文章:

iphone - 从电子邮件重定向到移动浏览器,然后重定向到应用程序

iphone - 如何查看以模态方式呈现的 View Controller

ios - 不会调用 Objective C 完成 block

ios - 尝试将 AlamoFire JSON 响应映射到类并接收 "Fatal Error: Unexpectedly found nil while unwrapping optional"

ios - 更改iOS锁屏的行为

ios - 传递的 Segue 变量在加载后保持清除

ios - 表格 View 原型(prototype)内容宽度错误

ios - 隐藏状态栏不起作用的iOS

objective-c - 在 iOS 应用程序中存储常量的最佳位置在哪里?

iphone - 创建笔记 View 的最佳方法