Here is how you can proceed,
class VCA: UIViewController {
@IBAction func onTapNextButton(_ sender: UIButton) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "VCB") as? VCB {
self.present(controller, animated: true, completion: nil)
}
}
}
Since VCC
is embedded in a UINavigationController
, you need to present UINavigationController
instead of VCC
.
For this subclass UINavigationController
and set it as class
of UINavigationController
in the storyboard
.
class VCB: UIViewController {
@IBAction func onTapNextButton(_ sender: UIButton) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "NavVC") {
self.dismiss(animated: false, completion: nil)
self.presentingViewController?.present(controller, animated: true, completion: nil)
}
}
}
class NavVC: UINavigationController {}
class VCC: UIViewController {
@IBAction func onTapCloseButton(_ sender: UIButton) {
self.navigationController?.dismiss(animated: true, completion: nil)
}
}