func previewRecording (withFileName fileURL: String) {
if UIVideoEditorController.canEditVideo(atPath: fileURL) {
let rootView = UIApplication.getTopMostViewController()
let editController = UIVideoEditorController()
editController.videoPath = fileURL
// editController.delegate = ?????
rootView?.present(editController, animated: true, completion: nil)
} else {
}
}^当前代码
我已经在互联网上转了几圈,试图弄清楚这一点。在这里为UIVideoEditorController指定委托的最佳方法是什么?这是一个react原生模块,其中没有ViewController,只有实用程序类。
我遇到过一些简单的示例代码
extension SomeViewController :
UIVideoEditorControllerDelegate,
UINavigationControllerDelegate {
func videoEditorController(_ editor: UIVideoEditorController,
didSaveEditedVideoToPath editedVideoPath: String) {
print("saved!")
}
}不过,我只是不知道如何在我的模块中实现这一点。
发布于 2018-09-16 03:03:16
@objc class ScreenRecordCoordinator: NSObject
{
let previewDelegateView = PreviewDelegateView()
// .......
editController.delegate = previewDelegateView
}
class PreviewDelegateView: UIViewController, UINavigationControllerDelegate, UIVideoEditorControllerDelegate {
var isSaved:Bool = false
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
print("save called")
if(!self.isSaved) {
self.isSaved = true
print("trimmed video saved!")
editor.dismiss(animated: true, completion: {
ReplayFileUtil.replaceItem(at: URL(fileURLWithPath: editor.videoPath), with: URL(fileURLWithPath: editedVideoPath))
self.isSaved = false
})
}
}
}https://stackoverflow.com/questions/52333099
复制相似问题