iOS:后台运行应用程序时在屏幕上隐藏敏感信息 [英] iOS: Hiding sensitive information on the screen when app is backgrounded

查看:185
本文介绍了iOS:后台运行应用程序时在屏幕上隐藏敏感信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前台应用程序变为背景(例如,按下主页"按钮)时,如何将最顶层视图控制器 prior 上的元素更改为iOS对其进行快照并启动动画以显示下一个屏幕?

When a foreground app gets backgrounded (e.g. Home button gets pressed), how can I change elements on the topmost view controller prior to when iOS takes a snapshot of it and starts the animation to show the next screen?

我问是因为我正在编写一个要求符合HIPAA要求的应用程序,而且我担心操作系统为执行此动画而拍摄的快照有时包含敏感数据,即使,这些数据也不可见稍后再显示应用程序时,请等待一秒钟.

I ask because I'm writing an app requiring HIPAA compliance, and I am concerned that the snapshot that the OS takes in order to do this animation sometimes contains sensitive data which should not be visible even for a split second when the app gets foregrounded later.

我知道视图控制器具有生命周期方法,例如viewWillDisappear可能是有用的,但是我有很多控制器,我宁愿在我的应用程序委托中添加一些内容来处理此问题(例如,通过添加一个不透明的全屏UIImageView叠加层),而不必在每个最后一个控制器中为此编写自定义代码.

I'm aware that view controllers have lifecycle methods such as viewWillDisappear which might be usable, but I have a lot of controllers and I'd rather just have something in my App Delegate to handle this (e.g. by adding an opaque full-screen UIImageView overlay) rather than having to write custom code for this in every last controller.

我曾尝试将生成叠加层的代码放入applicationWillResignActive中,并且一直在研究Apple的文档和Google,但无法正常工作.我怀疑屏幕截图是在应用程序有机会更新屏幕之前拍摄的.

I tried putting overlay-generating code in applicationWillResignActive, and I've been digging with Apple's docs and Google, but it's not working. I suspect the screenshot gets taken before the app has a chance to update the screen.

谢谢!

推荐答案

我相信答案是不要与背景动画开始之前改变屏幕上的内容有关,而只是修改内容当应用程序进入背景时(即,您的应用程序委托中applicationDidEnterBackground:内部)显示在屏幕上.这解决了我的问题.

I believe the answer is to not concern oneself with changing what's on the screen before the backgrounding animation begins, but to simply modify what's displayed on the screen once the app enters the background (i.e. inside of applicationDidEnterBackground: in your App Delegate.) This solved my problem.

我的UIImageView覆盖图想法在这里起作用,尽管我决定只是弹出到根视图控制器.这样更简单.我的根视图没有任何敏感信息.

My UIImageView overlay idea worked here, although I decided just to pop to the root view controller instead. Simpler that way. My root view doesn't have any sensitive info.

这是它的样子:

-(void)applicationDidEnterBackground:(UIApplication *)application {

    UINavigationController *navigationController = 
        (UINavigationController *)self.window.rootViewController;
    [navigationController popToRootViewControllerAnimated:NO];

    ...
}

这篇关于iOS:后台运行应用程序时在屏幕上隐藏敏感信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆