//当用户录屏 怎么办 目前来说 只能进行提示。监听到就返回上一页,并弹出提示
1,检测当前设备是否在录屏:
pragma mark -- 录屏
- (void)addLuPingJianTing{
//监测当前设备是否处于录屏状态
UIScreen * sc = [UIScreen mainScreen];
if (@available(iOS 11.0,*)) {
if (sc.isCaptured) {
NSLog(@"正在录制-----%d",sc.isCaptured);
// 延迟三秒去执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.navigationController popViewControllerAnimated:YES];
});
// 延迟三秒去执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NormalAlartView view = [[[NSBundle mainBundle] loadNibNamed:@"NormalAlartView" owner:self options:nil] lastObject];
view.isLuPing = YES;
view.titleLabel.text = LocalizedString(@"为保护教程版权,请停止录屏操作!");
view.sureBtn.hidden = YES;
[view.cancleBtn setTitle:LocalizedString(@"我知道了") forState:(UIControlStateNormal)];
[view show];
});
}
}
//ios11之后才可以录屏
if (@available(iOS 11.0,)) {
//检测设备
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(tipsVideoRecord) name:UIScreenCapturedDidChangeNotification object:nil];
}
}
iOS 11.0之后 可以通过通知检测检测设备录屏 - (void)tipsVideoRecord {
UIScreen * sc = [UIScreen mainScreen];
if (@available(iOS 11.0,*)) {
if (sc.isCaptured) {
// 延迟三秒去执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NormalAlartView *view = [[[NSBundle mainBundle] loadNibNamed:@"NormalAlartView" owner:self options:nil] lastObject];
view.isLuPing = YES;
view.titleLabel.text = LocalizedString(@"为保护教程版权,请不要录屏!");
view.sureBtn.hidden = YES;
[view.cancleBtn setTitle:LocalizedString(@"我知道了") forState:(UIControlStateNormal)];
[view show];
});
}
}
}
网友评论