Kordan Ou Kordan Ou - 8 months ago 54
Objective-C Question

How to change the text of UIBarButtonItem programmatically?

I've read this article:
Change the text of a UILabel (UIBarButtonItem) on a toolbar programmatically

But it seems not working for my auto-hide toolbar?

I also tried "barbuttonItem.title" to set the text, failed too.

Any idea? Much thanks!

Answer Source

Are you creating the button in Interface Builder? Make sure that the identifier is set to Custom, otherwise you will not be able to change the title.

Select the UIBarButtonItem in Interface Builder, open the inspector (Command + Shift + I), and select "Custom" under the dropdown next to "Identifier".