I have run into some odd behavior of UIBarButtonItem/UINavigationBar when I attempt to restore the state of a UINavigationController between launches.
The below code snippet shows how I restore the state of a navigation controller. This code snippet is executed in the viewDidLoad method.
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if ([ud objectForKey:HBStateRestorationQuoteSelection]) {
NSInteger index = [ud integerForKey:HBStateRestorationQuoteSelection];
// Fetch Quote
NSDictionary *quote = [self.quotes objectAtIndex:index];
// Initialize Quote View Controller
HBQuoteViewController *vc = [[HBQuoteViewController alloc] initWithNibName:@"HBQuoteViewController" bundle:[NSBundle mainBundle]];
vc.quote = quote;
// Push Quote View Controller Onto Navigation Stack
[self.navigationController pushViewController:vc animated:NO];
}
The result is that the back button title is truncated for some reason. This behavior is not present when the navigation controller is used in a normal fashion.
Note that the truncation is not due to the size of the title in the navigation bar. As I mentioned before, the title of the back bar button is displayed normal when I don't use this state restoration logic.
I also tried putting the restoration code in the viewWillAppear method or changing the title of the back bar button by creating a custom back bar button, but none of these approaches solve the problem.
