Kordan Ou Kordan Ou - 11 days ago 4
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

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".

Comments