控制iOS 7多任务切换器中的屏幕截图 [英] Controlling the screenshot in the iOS 7 multitasking switcher

查看:378
本文介绍了控制iOS 7多任务切换器中的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试查找有关iOS 7中新的多任务切换器的一些信息,特别是当应用程序进入休眠状态时操作系统所采用的屏幕截图。





有没有办法完全关闭此功能或截图?或者我可以从切换台完全隐藏应用程序吗?该应用程序需要在后台运行,但我们不希望显示该应用程序的任何屏幕截图。



屏幕截图可能具有安全风险,请考虑一下对于银行应用程序,任何人双击设备上的主页按钮都可以使用您的卡号或帐户摘要。



任何人对此有何见解?谢谢。

解决方案

iOS应用编程指南


在移至后台之前从视图中删除敏感信息。



当应用程序转换到后台时,系统会拍摄应用程序主窗口的快照,然后在将应用程序转换回前景时会快速显示该窗口。在从 applicationDidEnterBackground:方法返回之前,您应该隐藏或隐藏可能作为快照的一部分捕获的密码和其他敏感个人信息。


除了隐藏/替换敏感信息外,您可能还想告诉iOS 7不要通过 ignoreSnapshotOnNextApplicationLaunch 。根据此方法的文档


如果您认为快照无法正确反映应用的用户界面当您的应用重新启动时,您可以调用[ ignoreSnapshotOnNextApplicationLaunch ]来阻止拍摄快照图像。


话虽如此,似乎仍然拍摄了屏幕快照,因此我提交了一份错误报告。但是你应该进一步测试,看看使用这个设置是否有帮助。



如果这是一个企业应用程序,你可能还想查看<$ c $的相应设置c> allowScreenShot 配置文件参考的TP40010206-CH1-SW13rel =noreferrer>限制有效负载部分。






这是一个实现我所需要的实现。您可以展示自己的 UIImageView ,或者您可以使用委托协议模式来隐藏机密信息:

  // SecureDelegate.h 

#import< Foundation / Foundation.h>

@protocol SecureDelegate< NSObject>

- (void)hide:(id)object;
- (void)show:(id)object;

@end

然后我给了我的应用代表一个属性:

  @property(弱,非原子)id< SecureDelegate> secureDelegate; 

我的视图控制器设置它:

   - (void)viewDidLoad 
{
[super viewDidLoad];

AppDelegate * delegate = [[UIApplication sharedApplication] delegate];
delegate.secureDelegate = self;
}

视图控制器显然实现了该协议:

   - (void)hide:(id)object 
{
self.passwordLabel.alpha = 0.0;
}

- (void)show:(id)object
{
self.passwordLabel.alpha = 1.0;
}

最后,我的app委托使用了这个协议和属性:

   - (void)applicationWillResignActive:(UIApplication *)application 
{
[application ignoreSnapshotOnNextApplicationLaunch]; //这似乎不起作用,无论是在这里调用还是`didFinishLaunchingWithOptions`,但似乎谨慎包含它

[self.secureDelegate hide:@applicationWillResignActive:]; //你不需要传递对象,但在测试期间它很有用...
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
[self.secureDelegate show:@applicationDidBecomeActive:];
}

注意,我正在使用 applicationWillResignActive 而不是建议的 applicationDidEnterBackground ,因为正如其他人所指出的那样,当应用程序运行时双击主页按钮时不会调用后者。 / p>

我希望我可以使用通知来处理所有这些,而不是代理协议模式,但在我的有限测试中,通知不会及时处理 - 足够的方式,但上面的模式工作正常。


I've been trying to find some information regarding the new multitasking switcher in iOS 7 and especially the screenshot that the OS takes when the app is going into hibernation.

Is there any way to completely turn off this feature or screenshot? Or can I hide the app altogether from the switcher? The app needs to run in the background, but we do not want to show any screenshot from the app.

The screenshot is potentially a security-risk, think along the lines for banking-apps where your card number or account summary will be available to anyone that double-click on the home button on the device.

Anyone with any insight into this? Thanks.

解决方案

In the App Programming Guide for iOS, Apple says:

Remove sensitive information from views before moving to the background.

When an app transitions to the background, the system takes a snapshot of the app’s main window, which it then presents briefly when transitioning your app back to the foreground. Before returning from your applicationDidEnterBackground: method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.

In addition to obscuring/replacing sensitive information, you might also want to tell iOS 7 to not take the screen snapshot via ignoreSnapshotOnNextApplicationLaunch. According to the documentation for this method:

If you feel that the snapshot cannot correctly reflect your app’s user interface when your app is relaunched, you can call [ignoreSnapshotOnNextApplicationLaunch] to prevent that snapshot image from being taken.

Having said that, it appears that the screen snapshot is still taken and I have therefore filed a bug report. But you should test further and see if using this setting helps.

If this was an enterprise app, you might also want to look into the appropriate setting of allowScreenShot outlined in the Restrictions Payload section of the Configuration Profile Reference.


Here is an implementation that achieves what I needed. You can present your own UIImageView, or your can use a delegate-protocol pattern to obscure the confidential information:

//  SecureDelegate.h

#import <Foundation/Foundation.h>

@protocol SecureDelegate <NSObject>

- (void)hide:(id)object;
- (void)show:(id)object;

@end

I then gave my app delegate a property for that:

@property (weak, nonatomic) id<SecureDelegate> secureDelegate;

My view controller sets it:

- (void)viewDidLoad
{
    [super viewDidLoad];

    AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    delegate.secureDelegate = self;
}

The view controller obviously implements that protocol:

- (void)hide:(id)object
{
    self.passwordLabel.alpha = 0.0;
}

- (void)show:(id)object
{
    self.passwordLabel.alpha = 1.0;
}

And, finally, my app delegate avails itself of this protocol and property:

- (void)applicationWillResignActive:(UIApplication *)application
{
    [application ignoreSnapshotOnNextApplicationLaunch];  // this doesn't appear to work, whether called here or `didFinishLaunchingWithOptions`, but seems prudent to include it

    [self.secureDelegate hide:@"applicationWillResignActive:"];  // you don't need to pass the "object", but it was useful during my testing...
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [self.secureDelegate show:@"applicationDidBecomeActive:"];
}

Note, I'm using applicationWillResignActive rather than the advised applicationDidEnterBackground, because, as others have pointed out, the latter is not called when double tapping on the home button while the app is running.

I wish I could use notifications to handle all of this, rather than the delegate-protocol pattern, but in my limited testing, the notifications aren't handled in a timely-enough manner, but the above pattern works fine.

这篇关于控制iOS 7多任务切换器中的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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