I have a navigation controller with three views. Possible navigation routes are:
VC1 -> VC3
and
VC1 -> VC2 -> VC3
When a user goes from VC1 to VC2 and ends up in VC3, I would like the back button in the navigation bar to point to VC1 (and not VC2). So in VC2, I added this piece of code.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
self.navigationController?.popViewController(animated: true)
}
It works; but I can see the pop happening. When I am on VC2 and in the process of navigating to VC3, I can see VC1 for a second (VC2 has been popped from the stack) and then I see VC3. It doesn't look nice.
Is there a better way of doing this?
Thanks.