In Xcode 4.5.1, creating a storyboard application with a navigation controller, I find it difficult to set the BACK button for any view controllers that have been pressed. I am using segue and the view controller shows as expected. However, I want to dynamically change the name of the navigation bar and back button and put this in my ViewWillAppear:
self.title = @"Select Songs"; [self.backButton setTitle:@"Add"];
changes the name of the navigation bar, but the back button still displays the name NAME in the pressed window, rather than the text Add.
Simulated metrics are all inferred. I also added a BarButtonItem to the black tray under the view in Xcode and connected the backButton to the viewcontroller to the backButton, but the text is still not displayed.
Adding the following log messages also gives something interesting: (and yet the header is updated correctly)
-(void) viewDidAppear:(BOOL)animated { NSLog(@"%s %@", __FUNCTION__, self.navigationItem.backBarButtonItem); NSLog(@"%s %@", __FUNCTION__, self.navigationController.navigationItem.backBarButtonItem); } 2012-10-14 15:18:41.835 xxxx[2690:907] -[ViewController viewDidAppear:] (null) 2012-10-14 15:18:41.838 xxxx[2690:907] -[ViewController viewDidAppear:] (null)
source share