在迅速 3.2
第一的:
class ViewController: UIViewController, RPPreviewViewControllerDelegate {
func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
previewController.dismiss(animated: true, completion: nil)
}
}
然后当停止录制按钮调用时,并将委托设置为关闭
if RPScreenRecorder.shared().isRecording {
RPScreenRecorder.shared().stopRecording { (previewController: RPPreviewViewController?, error: Error?) in
if previewController != nil {
let alertController = UIAlertController(title: "Recoring", message: "Do you wish to discard or view your recording?", preferredStyle: .alert)
let discardAction = UIAlertAction(title: "Discard", style: .destructive, handler: nil)
let viewAction = UIAlertAction(title: "View", style: .default, handler: { (action: UIAlertAction) in
// set delegate here
previewController?.previewControllerDelegate = self
self.present(previewController!, animated: true, completion: nil)
})
alertController.addAction(discardAction)
alertController.addAction(viewAction)
self.present(alertController, animated: true, completion: nil)
}
}
}