Kordan Ou Kordan Ou - 1 year ago 107
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".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download