Can't customize back button on UINavigationViewController

77 views Asked by At

I've got a set of views embedded in a navigation view controller.

The way it works is that a button in the first viewController (embedded already in navVC) transitions w/"Show (e.g. Push)" which causes a "< Cancel" button text to appear in the top left.

Then I tap a cell which does another "Show (e.g. Push)" transition to a third vc which show "< Back" button.

I'm happy with the way the "< Back" button appears, but I want to remove the "<" from the "< Cancel" button so it just says "Cancel" with no arrow.

How can I override the back button to just show the title text, and also not pass that behavior along to further controllers in the series?"

1

There are 1 answers

0
HangarRash On BEST ANSWER

Given the behavior you are describing, it sounds like it would make more sense to present the 2nd view controller as a modal in its own navigation controller. Then you can add Save and Cancel (or whatever you need) UIBarButtonItem buttons to the leftBarButtonItem and rightBarButtonItem of the 2nd view controller's navigationItem. The 3rd view controller can still be pushed as needed.

If you really do want to simply push the 2nd view controller but replace the standard back button then in the 2nd view controller you can set its navigationItem.leftBarButtonItem to a new UIBarButtonItem as needed. The left bar button item will be shown in place of the default back button.