Question

I have View Controller inside of Navigation Controller. It has default back button with title of previous controller in navigation controller's stack. But button dont resize to text width. So it looks like this: http://gyazo.com/0f94d7802354cadaee7d4aa38b1eea8e (I'm sorry i can't add images)

But when I open setting in simulator I see that text fit back button: http://gyazo.com/d3a512ce41885896a4ebe04ed1ca2a0c

How can I reach the same behavior? Thanks.

Was it helpful?

Solution

I've found that the back button will resize automatically to fit the text. Are you customizing your title? It doesn't look like the default so perhaps this is the problem. You could try truncating the title manually or making a custom back button:

self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:
@"Custom Back Title" style:UIBarButtonItemStyleBordered target:nil action:nil]
autorelease];

This should be added to the view controller one level up (so the one that would be displayed by tapping back, not the one in which the button appears).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top