如何从应用程序中的任何其他VC转到已实例化的现有视图控制器。
这是我的情况:
我正在与另一个用户进行语音通话的VC上。我可以导航到应用程序中的任何其他VC。我想从任何其他VC回到这个调用VC。我该怎么办?
类似于以下使用笔尖的代码,但我希望在情节提要中使用此功能
@objc func buttonTapped(sender: UIButton!) {
if let vc = Bundle.main.loadNibNamed("CallViewController", owner: nil, options: nil)?.first as? CallViewController {
self.present(vc, animated: true, completion: nil)
}
}
因此,基本上,您只需要以下代码即可导航到视图控制器并返回:
class ViewController: UIViewController {
func gotoSomeOtherViewController() {
present(SomeOtherViewController(), animated: true)
}
}
class SomeOtherViewController: UIViewController {
func goBackToViewController() {
dismiss(animated: true)
}
}