Hello,
so i have this storyboard
structure i have a button
in ViewController B
i need that button
to point to the bottom NavigationController
in which it has the ViewController C
as rootViewController
so when i press a button
in ViewContoller B
it takes me to C
now i need a back button on C
to take me back to B
i have tried looking but all of the reference materials show how to navigate between ViewController
not NavigationControllers
I think you cannot push Navigation Controller inside another uinavigation controller but alternativaly you can present another nav controller. Hope it works for you. I have created simple demo like this.
class ViewController: UIViewController {
@IBOutlet weak var btnCustom: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func btnForward(_ sender: Any) {
/*Uncomment the code if you want to present programatically*/
/*if let navi2 = self.storyboard?.instantiateViewController(withIdentifier: "nav2"){
self.present(navi2, animated: true) {
}
}*/
}
}
class ViewController2: UIViewController {
@IBOutlet weak var btnCustom: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnBack(_ sender: Any) {
if let parentNav = self.navigationController {
parentNav.dismiss(animated: true) {
}
}
}}