Override navigation controller back button

135 views Asked by At

I have a UIViewController called detailViewController that I push to from homeViewController.

In detailViewController there is a container that will display subview A, B and C.

If I tap the back button in the navigation bar, the navigation pops to homeViewController, as expected. I'd like to override the back button so that if the container is displaying subview B, the container updates to show subview A (and likewise, subview C goes to subview B). And if we're displaying subview A then pop back to homeViewController as expected.

Essentially, I need to be able to tap the back button but force the navigation to not pop to the previous view. Is that possible?

I know I could hide the back button and replace it with a custom bar button item but I don't want to do that. I want to keep the exact styling of the native back button.

0

There are 0 answers