我在 swift 2 中使用了这段代码,它有效。但是现在在 Swift 3 中,当我按下取消或保存按钮时,录制完成时弹出的预览控制器窗口不会关闭。我究竟做错了什么?
func stopRecording() {
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording(handler: { (previewController: RPPreviewViewController?, error) in
if previewController != nil {
print("stopped recording")
self.previewViewController.previewControllerDelegate = self
self.view?.window?.rootViewController?.present(previewController!, animated: true, completion: nil)
}
func previewControllerDidFinish(previewController: RPPreviewViewController) {
previewController.dismiss(animated: true, completion: nil)
}