我使用的是UIVideoEditorController,但success委托方法为我调用了两次。然而,所有传递的对象的所有指针都告诉它发送完全相同的数据。
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“两次。
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
print("here")
self.dismiss(animated: true, completion: nil)
}发布于 2019-11-29 01:47:13
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
editor.delegate = nil
editor.dismiss(animated: true)
}发布于 2018-08-07 18:51:07
是的,我知道,这种方式很糟糕,但在工作中:)
var isSaved:Bool = false
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
if(!isSaved) {
print("here")
self.isSaved = true
}
self.dismiss(animated: true, completion: nil)
}发布于 2018-08-07 19:02:44
你能调试一下,你UIViewController使用UIVideoEditorController重新分配时,用户离开屏幕正确。例如在离开屏幕或从屏幕返回之后。
可能是内存中UIViewController的一个对象,这就是方法调用两次的原因。
用于调试此的
deinit{ print("deallocating") } for you UIViewController.deinit{ print("deallocating") }。希望能对你有所帮助。:)
https://stackoverflow.com/questions/50795848
复制相似问题