Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Push from presented ViewController?

What I want to do is:

VC1 -> present VC2 -> push VC3

this is the normal flow I want to make.

after that on back button(on each VC have back button)

I required to show user as moving back:

VC3 -> present VC2 -> VC1

How do I achieve this kind of navigation in Swift 5?

like image 503
manoj kashyap Avatar asked May 14 '26 12:05

manoj kashyap


1 Answers

//VC1
@IBAction func presentVC2() {
    let vc2 = VC2()
    vc2.modalPresentationStyle = .fullScreen
    self.present(vc2, animated: true, completion: nil)
}

//VC2
@IBAction func presentVC3() {
    let vc3 = VC3()
    let navController = UINavigationController(rootViewController: vc3) //Add navigation controller
    navController.modalPresentationStyle = .fullScreen
    self.present(navController, animated: true, completion: nil)
}

//VC3
@IBAction func navigationVC4() {
    let vc4 = VC4()
    self.navigationController?.pushViewController(vc4, animated: true)
}
like image 162
Ramprasath Selvam Avatar answered May 17 '26 00:05

Ramprasath Selvam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!