func startRecording() {
let recorder = RPScreenRecorder.shared()
recorder.startRecording(withMicrophoneEnabled: false, handler: { (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.videoRecButton.addTarget(self, action:#selector(self.stopRecording), for: .touchUpInside)
}
})
}
func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecording { [unowned self] (preview, error) in self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(self.startRecording))
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.present(unwrappedPreview, animated: true)
}
}
}
在 recorder.startRecording() 和 recorder.stopRecording()... 它生成错误为“无法完成操作。(com.apple.ReplayKit.RPRecordingErrorDomain 错误 -5803。)”
我也没有获得许可弹出窗口。