是否可以禁用屏幕录制?还是可以通过配置文件进行配置?或任何第三方库可用?
答案 0 :(得分:6)
NotificationCenter.default.addObserver(self, selector: #selector(preventScreenRecording), name: NSNotification.Name.UIScreenCapturedDidChange, object: nil)
并在主视图内创建一个视图,并防止出现这种情况。
(void) preventScreenRecording {
if (@available(iOS 11.0, *)) {
BOOL isCaptured = [[UIScreen mainScreen] isCaptured];
if (isCaptured) {
self.blockView.hidden = false;
}
else {
self.blockView.hidden = true;
}
}
答案 1 :(得分:3)
启动应用后,您可以测试UIScreen.isCaptured
属性,并在设置为true
的情况下显示一些初始屏幕。
您还应该观察capturedDidChangeNotification
notification(在某个地方订阅),如果将UIScreen.isCaptured
设置为true
,请做同样的事情(显示初始屏幕)。
答案 2 :(得分:1)
sharedRecorder.stopRecording( handler: { previewViewController, error in
if let error = error {
print("\(error.localizedDescription)")
}
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
previewViewController?.modalPresentationStyle = UIModalPresentationStyle.popover
previewViewController?.popoverPresentationController?.sourceRect = CGRect.zero
previewViewController?.popoverPresentationController?.sourceView = self.view
}
if previewViewController != nil {
self.previewViewController = previewViewController
previewViewController?.previewControllerDelegate = self
}
self.present(previewViewController!, animated: true, completion: nil)
})
return
}
https://developer.apple.com/documentation/replaykit/rpscreenrecorder/1620990-stoprecording