从多任务处理回来时阻止您的应用程序的快照视图您的、快照、视图、应用程序

2023-09-06 23:13:41 作者:莫失莫忘莫心动

问题是这样的 - 我的应用程序可以让您通过密码保护自己.我使用一个界面,就像保护手机的密码一样.这一直很好,直到出现多任务处理.

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.