首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两次调用UIVideoEditorController委托方法

两次调用UIVideoEditorController委托方法
EN

Stack Overflow用户
提问于 2018-06-11 18:40:19
回答 4查看 1.1K关注 0票数 8

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

代码语言:javascript
复制
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“两次。

代码语言:javascript
复制
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    print("here")
    self.dismiss(animated: true, completion: nil)
}
EN

回答 4

Stack Overflow用户

发布于 2019-11-29 01:47:13

代码语言:javascript
复制
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    editor.delegate = nil
    editor.dismiss(animated: true)
}
票数 5
EN

Stack Overflow用户

发布于 2018-08-07 18:51:07

是的,我知道,这种方式很糟糕,但在工作中:)

代码语言:javascript
复制
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
EN

Stack Overflow用户

发布于 2018-08-07 19:02:44

你能调试一下,你UIViewController使用UIVideoEditorController重新分配时,用户离开屏幕正确。例如在离开屏幕或从屏幕返回之后。

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

用于调试此的

  • create deinit{ print("deallocating") } for you UIViewController.
  • add break on print。
  • 然后确保正在调用deinit{ print("deallocating") }

希望能对你有所帮助。:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50795848

复制
相关文章

相似问题

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