I'm trying to pop to a viewcontroller which I believe is at index 0. My ViewController name is HomeVC.
self.navigationController!.popToViewController(self.navigationController!.viewControllers[0] as! UIViewController, animated: true)
However, the code above only pops me back to the most recent viewcontroller. Not sure why it's not going to my HomeVC viewcontroller. Is their a way I can use the ViewController Name to pop to it?
Add following
UINavigationController
extensionUse as follows
Try this:
You can use
popToRootViewControllerAnimated
to pop to the View controller at index zero.It returns an array of view controllers that were popped, that might help you in debugging the issue.
I solved it like this.