防止应用程序的快照视图

防止应用程序的快照视图

本文介绍了从多任务处理回来时,防止应用程序的快照视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是这个 - 我的应用程序允许你密码保护自己。我使用的界面就像保护手机的密码一样。这一直很好,直到多任务出现。

The problem is this - My app lets you passcode protect itself. I use an interface just like passcode protecting the phone. This has always worked fine, until multi-tasking came along.

密码保护仍然有效,但有一个问题。 Apple做了一些特别的事情,让它看起来像我们的应用程序在从后台返回时加载速度更快。操作系统在用户离开应用程序之前会显示我们的屏幕图片,并显示该应用程序的其余部分仍在加载。

The passcode protection still works, but there is one issue. Apple does something special to make it look like our apps are loading quicker when they come back from the background. The os takes a picture of our screen just before the user leaves the app, and it displays that while the rest of the app is still loading.

这导致的问题是有人试图去我的应用程序会在密码保护开始之前看到屏幕的图像。当然,它并不多,但我认为我的用户不会想到人们能够得到一点点的一瞥他们的数据。

The problem this causes is that someone trying to go to my app would see that image of the screen before the passcode protection kicked in. Granted, it's not much, but I don't think my users will like the idea of people being able to get even a little glimpse of their data.

如何停止显示快照图像?

How to stop that snapshot image from showing?

推荐答案

我解决了这个。以下是解决方案:

I solved this. Here is the solution:

- (void)applicationDidEnterBackground:(UIApplication *)application{
    if (appHasPasscodeOn){
        UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
        splashView.image = [UIImage imageNamed:@"Default.png"];
        [window addSubview:splashView];
        [splashView release];
    }
}

Default.png是我的应用程序的屏幕截图空白屏幕(对我而言,它只是一个空白的列表视图)。上面的代码在应用程序进入后台之前将它放在我的真实视图前面。所以,当你回到你看到的应用程序时。瞧。

Default.png is a screenshot of my app with a blank screen (for me it's just a blank listview). The code above puts that in front of my real view right before the app goes into the background. So, when you come back to the app that is all you see. Voila.

这篇关于从多任务处理回来时,防止应用程序的快照视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 20:55