首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我正在处理的模块只是类时,我如何在ReactNative中为UIVideoEditorController指派委托

当我正在处理的模块只是类时,我如何在ReactNative中为UIVideoEditorController指派委托
EN

Stack Overflow用户
提问于 2018-09-14 21:30:45
回答 1查看 292关注 0票数 0
代码语言:javascript
复制
    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,只有实用程序类。

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

代码语言:javascript
复制
extension SomeViewController : 
    UIVideoEditorControllerDelegate, 
    UINavigationControllerDelegate {

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

    print("saved!")
  }
}

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

EN

回答 1

Stack Overflow用户

发布于 2018-09-16 03:03:16

代码语言:javascript
复制
    @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
                })
            }
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52333099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档