One behavior I observed in iOS 7 is that the title of the backBarButtonItem
of a UINavigationItem
get's renamed if the title of the currently displayed view controller is too long. Too lazy to explain so here are some photos:
As you can see, when the title is too long, the back button gets renamed to "Back" regardless of what it was previously. If the title is even longer, the back button doesn't show any text, just the left arrow image.
Does anyone know how to disable this behavior? I would like the back button to stay exactly what I want it to be and not get renamed. Thanks
I created a dirty solution by manually constraining the width of the title of the view controller. I discovered that the font of the title on iPhone is System Bold 17.0, so I do a check for what the size the title will be before setting it (via the sizeWithAttributes:
method of strings), and trim characters off the end of the title until the size is shorter than the length that causes the back button to get renamed.
iOS 7 will automatically replace your back button title with "Back" or even remove the title altogether in order to fit the title of current navigation item. You probably shouldn't try to do anything about it except maybe try and make your titles shorter.
if you want to make short title you can do as below
self.title = @"SOME REALLY LONG NAVIGATION BAR TITLE";
UILabel* label=[[UILabel alloc] initWithFrame:CGRectMake(0,0, 200, 40)];
label.text=self.navigationItem.title;
label.adjustsFontSizeToFitWidth=YES;
self.navigationItem.titleView=label;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With