Reputation: 31225
Background
I am developing an application which contains a top nav bar with an icon that allows to go back to the main ViewController
.
As there as several ViewController
s, I don't want to duplicate the segue on each ViewController
. I would prefer to create a custom class for the top nav bar and be able to programmatically present the main ViewController
. I found that I could maybe call present(viewControllerToPresent:animated:completion)
Questions
Also, as the main ViewController has already been instantiated when the application started, do I need to instantiate a new one or can I get a reference to the existing one?
Upvotes: 0
Views: 48
Reputation: 615
So if I get this correct you click mainVC->firstVC->secondVC->nthVC and then you'd want to go directly back to mainVC ? View controllers are stacked so what I'd do is just dismiss all those view controllers that are above mainVC.
Upvotes: 1