Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIVideoEditorController delegate method called twice

I'm using UIVideoEditorController, but the success delegate method called twice for me. However, all pointers of all passed objects tell it sends exactly the same data.

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)

And then the following method prints "here" 2 times.

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    print("here")
    self.dismiss(animated: true, completion: nil)
}
like image 329
Stas Ivanov Avatar asked Jun 11 '18 10:06

Stas Ivanov


2 Answers

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    editor.delegate = nil
    editor.dismiss(animated: true)
}
like image 138
Василь Чекун Avatar answered Nov 15 '22 04:11

Василь Чекун


yes, I know, this bad way but workin :)

var isSaved:Bool = false

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
   if(!isSaved) {
      print("here")
      self.isSaved = true
   }
       self.dismiss(animated: true, completion: nil)
   }
like image 20
e.john Avatar answered Nov 15 '22 03:11

e.john