iOS 11:是否可以屏蔽录屏?

iOS 11: Is it possible to block screen recording?

我有一个播放视频的应用程序,我不希望人们使用新的 iOS-11 功能来录制这些视频并制作它们 public。 here.

描述了该功能

我找不到任何关于我的应用阻止用户录制的选项的文档。

任何人都可以指导我做任何与此相关的事情吗?

谢谢!

我在这里发布 Apple 开发者技术支持 (DTS) 的官方回复:

虽然没有办法阻止屏幕录制,但作为 iOS11 的一部分,UIScreen 上有新的 API,应用程序可以使用这些 API 来了解屏幕何时被捕获:

屏幕内容可以被记录、镜像、通过 AirPlay 发送,或以其他方式克隆到另一个目的地。当屏幕捕获状态发生变化时,UIKit 发送 UIScreenCapturedDidChange 通知。

通知的对象是isCaptured属性改变的UIScreen对象。没有 userInfo 字典。然后,您的应用程序可以处理此更改并防止您的应用程序内容以任何适合您使用的方式被捕获。

HTH!

该功能在 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];

        }];

    }

}

}