I have the navigation as:
List of Friends with messages Controller (click compose) -> List of friends to select chatting (select friend) -> Show chat with friend
At present, if within Show chat with friend, and the user selects back, it takes them to the List of friends to select chatting controller.
I wish to skip over this controller and, upon back selection, navigate to List of Friends with messages Controller
Note: the List of Friends with messages Controller is an embedded within a tab.
I have attempted using: self.navigationController?.viewControllers.removeLast(), within the segue between the List of friends to select chatting to remove it from the stack. But then after the navigating to Show chat with friend, the back button disappears...
How can I allow the navigation I am describing?
If your goal is to skip second UIViewControllerand pop back to first UIViewController from third UIViewController. Try the following code:
// This count will return how many view controllers are there in navigation stack
let controllersInNavigationCount = self.navigationController?.viewControllers.count
// This will pop to first UIViewController skipping second UIViewController
self.navigationController?.popToViewController(self.navigationController?.viewControllers[controllersInNavigationCount!-2] as! FirstViewController, animated: true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With