0

这段代码以前可以工作,但自从我更新到 swift 3 后,当我按下保存按钮时,屏幕录像不再保存在我的照片库中。当我按下保存按钮或取消按钮时,我也会在控制台中收到此错误消息。

[常见] _BSMachError: 端口 5a37; (os/kern) 无效名称 (0xf) “无法解除分配发送权”

这是我在屏幕录制结束并显示 previewViewController 时使用的代码:

internal func previewControllerDidFinish(_ previewViewController: RPPreviewViewController) {

previewViewController.dismiss(animated: true, completion: nil)

}
4

1 回答 1

0

//试试这个代码希望它有帮助:

func startRecording() { 让记录器 = RPScreenRecorder.shared()

if #available(iOS 9.0, *) {
    recorder.startRecording(withMicrophoneEnabled: true) { [unowned self] (error) in
        if let unwrappedError = error {
            print(unwrappedError.localizedDescription)
        } else {
            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .plain, target: self, action: #selector(PreviewVC.stopRecording))
        }
    }
} else {
    // Fallback on earlier versions
}

}

func stopRecording() { 让记录器 = RPScreenRecorder.shared()

recorder.stopRecording { [unowned self] (preview, error) in
    self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(PreviewVC.startRecording))

    if let unwrappedPreview = preview {
        unwrappedPreview.previewControllerDelegate = self
        self.present(unwrappedPreview, animated: true, completion: nil)
    }
}

}

func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
    self.dismiss(animated: true, completion: nil)
}
于 2017-08-10T13:23:41.273 回答