BackBarButtonItem is renamed in iOS 7 when there is a long name

One of the actions that I observed in iOS 7 is that the header backBarButtonItem of UINavigationItem gets renamed if the title of the current controller is displayed too long. Too lazy to explain, so here are a few photos:

Screenshot with short title and desired back button

Long title renames back button to "Back"

As you can see, when the title is too long, the Back button is renamed to Back, regardless of what it was before. If the title is even longer, the back button does not display text, just the image of the left arrow.

Does anyone know how to disable this behavior? I would like the Back button to stay exactly what I want and not to be renamed. Thanks

EDIT

I created a dirty solution by manually limiting the width of the title bar of the view controller. I found that the title font on the iPhone is System Bold 17.0, so I check what size the title will have before setting it (using the sizeWithAttributes: string method, and trim the characters from the end until the size is less than the length, which will force the back button to rename.

+8
uiviewcontroller ios7 uinavigationitem uinavigationcontroller backbarbuttonitem
source share
1 answer

iOS 7 will automatically replace the title of the back button or even completely delete the title to match the title of the current navigation item. You probably shouldn't be trying to do anything about it, except maybe try making your headlines shorter.

if you want to make a short headline you can do it 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; 
+3
source share

All Articles