UIVideoEditorController委托方法调用两次

时间:2018-06-11 10:40:19

标签: ios swift uivideoeditorcontroller

我正在使用UIVideoEditorController,但成功委托方法为我调用了两次。但是,所有传递的对象的所有指针都告诉它发送完全相同的数据。

let editor = UIVideoEditorController()
editor.videoMaximumDuration = 10.0
editor.videoQuality = .typeIFrame1280x720
editor.delegate = self
editor.videoPath = // some path goes here
self.present(editor, animated: true, completion: nil)

然后以下方法打印" here" 2次。

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    print("here")
    self.dismiss(animated: true, completion: nil)
}

4 个答案:

答案 0 :(得分:1)

是的,我知道,这很糟糕,但是:in

var isSaved:Bool = false

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
   if(!isSaved) {
      print("here")
      self.isSaved = true
   }
       self.dismiss(animated: true, completion: nil)
   }

答案 1 :(得分:0)

请您调试用户离开屏幕时使用UIVideoEditorController正确分配的UIViewController吗?就像离开屏幕或从屏幕返回后一样。

可能是您的UIViewController在内存中的一个对象,这就是您的方法调用两次的原因。

要调试

  • 为您的UIViewController创建deinit{ print("deallocating") }
  • 添加断点。
  • 然后确保deinit被调用。

希望它会对您有所帮助。 :)

答案 2 :(得分:0)

这对我有用

socket

答案 3 :(得分:0)

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    editor.delegate = nil
    editor.dismiss(animated: true)
}
相关问题