【问题标题】:ViewWillAppear is not calling at the dismisal of modalview controllerViewWillAppear 没有在模态视图控制器的解散时调用
【发布时间】:2019-06-11 02:45:24
【问题描述】:

我有两个班级 A 和 B 。

class A{ 

override func viewWillAppear(_ animated: Bool) { . 

print("")
}

     let myPost = self.storyboard?.instantiateViewController(withIdentifier: "Completed") as! Completed

        myPost.transitioningDelegate = self as? UIViewControllerTransitioningDelegate
        myPost.modalPresentationStyle = .custom

        self.present(myPost, animated: true, completion: nil)

}
class B{ . 

 dismiss(animated: true, completion: nil)
}

在这里,我展示了 A 类的 B 类。但是当我解散 B 类时,viewWillApper(在 A 类中)没有调用。如何做到这一点?

【问题讨论】:

  • 能否请您edit 提出您的问题并发布实际复制您的问题的相关代码。

标签: ios delegates


【解决方案1】:

您可以使用 viewdidload() 或 awakefromnib() 来调用其他控制器,例如 B 中的 A 或 B 中的 B 一个

【讨论】:

  • 嗨 Mayank,当我回到 B 到 A 时,这些,viewdidload() 或 awakefromnib() 都没有工作
  • 当你解散一个控制器时,后面的控制器已经加载了。因此,如果您想在解雇时执行任何功能,您可以将其放在解雇方法中,或者可以使用 segue 或推送控制器,然后视图 didLoad() 将被调用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多