我有一个播放视频的应用,我不希望人们使用新的iOS-11功能录制这些视频并将其公开。该功能的描述为here。
我找不到任何关于我的应用程序选项的文档,以防止用户录制它。
有人可以指导我做与此相关的事吗?
谢谢!
答案 0 :(得分:10)
我在这里发布Apple开发者技术支持(DTS)的官方回复:
虽然没有办法阻止屏幕录制,但作为iOS 11的一部分,UIScreen上有新的API,应用程序可以使用这些API来了解捕获屏幕的时间:
屏幕内容可以录制,镜像,通过AirPlay发送,或以其他方式克隆到另一个目的地。当屏幕的捕获状态发生变化时,UIKit会发送UIScreenCapturedDidChange通知。
通知的对象是更改了isCaptured属性的UIScreen对象。没有userInfo字典。然后,您的应用程序可以处理此更改,并防止以适合您使用的任何方式捕获您的应用程序内容。
HTH!
答案 1 :(得分:0)
此功能在iOS11及更高版本上可用。最好将其保留在didFinishLaunchingWithOptions
中Objective-C语法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (@available(iOS 11.0, *)) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenCaptureChanged) name:UIScreenCapturedDidChangeNotification object:nil];
}
return YES;
}
-(void)screenCaptureChanged{
if (@available(iOS 11.0, *)) {
BOOL isCaptured = [[UIScreen mainScreen] isCaptured];// will keep on checking for screen recorder if it is runnuning or not.
if(isCaptured){
UIView *colourView = [[UIView alloc]initWithFrame:self.window.frame];
colourView.backgroundColor = [UIColor blackColor];
colourView.tag = 1234;
colourView.alpha = 0;
[self.window makeKeyAndVisible];
[self.window addSubview:colourView];
// fade in the view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 1;
}];
}else{
// grab a reference to our coloured view
UIView *colourView = [self.window viewWithTag:1234];
// fade away colour view from main view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 0;
} completion:^(BOOL finished) {
// remove when finished fading
[colourView removeFromSuperview];
}];
}
} else {
// Fallback on earlier versions
// grab a reference to our coloured view
UIView *colourView = [self.window viewWithTag:1234];
if(colourView!=nil){
// fade away colour view from main view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 0;
} completion:^(BOOL finished) {
// remove when finished fading
[colourView removeFromSuperview];
}];
}
}
}