0
    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-native 模块,其中没有 ViewController,只有实用程序类。

我遇到的一些简单的示例代码

extension SomeViewController : 
    UIVideoEditorControllerDelegate, 
    UINavigationControllerDelegate {

  func videoEditorController(_ editor: UIVideoEditorController, 
    didSaveEditedVideoToPath editedVideoPath: String) {

    print("saved!")
  }
}

不过,我只是不知道如何在我的模块中实现这一点。

4

1 回答 1

0
    @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
                })
            }
        }
    }
于 2018-09-15T19:03:16.267 回答