gpt4 book ai didi

ios - 在 iOS 7 多任务切换器中控制屏幕截图

转载 作者:IT王子 更新时间:2023-10-29 07:29:50 27 4
gpt4 key购买 nike

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

enter image description here

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

屏幕截图有潜在的安全风险,想想银行应用程序,只要双击设备上的主页按钮,任何人都可以看到您的卡号或帐户摘要。

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

最佳答案

Preparing Your UI to Run in the Background ,苹果说:

Prepare Your UI for the App Snapshot

At some point after your app enters the background and your delegate method returns, UIKit takes a snapshot of your app’s current user interface. The system displays the resulting image in the app switcher. It also displays the image temporarily when bringing your app back to the foreground.

Your app’s UI must not contain any sensitive user information, such as passwords or credit card numbers. If your interface contains such information, remove it from your views when entering the background. Also, dismiss alerts, temporary interfaces, and system view controllers that obscure your app’s content. The snapshot represents your app’s interface and should be recognizable to users. When your app returns to the foreground, you can restore data and views as appropriate.

参见 Technical Q&A QA1838: Preventing Sensitive Information From Appearing In The Task Switcher

除了隐藏/替换敏感信息外,您可能还想告诉 iOS 7 不要通过 ignoreSnapshotOnNextApplicationLaunch 截取屏幕快照。 ,其文档说:

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.

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

如果这是一个企业应用程序,您可能还想查看 Restrictions Payload 中概述的 allowScreenShot 的适当设置。 配置文件引用部分。


这是实现我需要的实现。您可以展示自己的 UIImageView,或者您可以使用委托(delegate)协议(protocol)模式来隐藏 secret 信息:

//  SecureDelegate.h

#import <Foundation/Foundation.h>

@protocol SecureDelegate <NSObject>

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

@end

然后我为此给了我的应用委托(delegate)一个属性:

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

我的 View Controller 设置它:

- (void)viewDidLoad
{
[super viewDidLoad];

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

View Controller 显然实现了该协议(protocol):

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

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

最后,我的应用代理利用了这个协议(protocol)和属性:

- (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:"];
}

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

我希望我可以使用通知来处理所有这些,而不是委托(delegate)协议(protocol)模式,但在我有限的测试中,通知没有及时处理,但上述模式工作正常。

关于ios - 在 iOS 7 多任务切换器中控制屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18959411/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com