This is what xcode does by default: WHen you are viewing the first view in a navigation controller, the “back” button does not appear in the header. The back button only appears when you travel to another view instantiated by the first view.
I want a home button, or back button to appear while you are on the first view. Clicking on it will perform a certain action….like say change the rootviewcontroller. How can I get this button to appear and how do I override it’s behaviour only when on the first view? The behaviour of the backbutton should work as default when on any other view.
In your root view controller’s
viewDidLoadmethod, initialize aUIBarButtonItemand add it to the navigation controller’s toolbar:The
targetshould be your application delegate class if you want to swap out root view controllers. Create a method in that class calledchangeRootViewControllerto perform the view controller swap.You can change the
homeButtonto use an image instead of text usinginitWithImage:.