Search code examples
iphoneiosios4uiviewcontrolleruinavigationcontroller

Change View Title when Navigating Back from a (Sub) View


I have a RootView with 5 buttons. When a button is pressed, I change the title of the current view (so the Back Button is brief) before displaying the selected view. When transitioning to the new (sub) view, I send the pushViewController message to the NavigationController through the AppDelegate.

When the Back Button is selected in the sub-view, I would like to change the title back to the verbose title.

Could anyone point out how I would accomplish the title change of the RootView when leaving a sub view?


Solution

  • Set the title in viewWillAppear of you RootView:

    - (void)viewWillAppear:(BOOL)animated {
        self.title = @"RootView";
    }
    

    If you use the back button on a sub-view, the root view will get the right title.