views:

1202

answers:

1

Through Interface Builder I have the ability to change the Identifier of a UIBarButtonItem to something like "Add" (or "Undo", "Redo" etc...). This gives my button a nice "+" image.

How can I set this programatically? The UIBarButtonItem does not accept a "setIdentifier" message.

+2  A: 

Figured it out myself:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(doAddAction:)];
rein
Your title for this post is misleading. This doesn't change the identifier of a UIBarButtonItem, it just creates a new one with the identifier property initialized. I'm looking for a way to modify the identifier on an existing button. A better title would be "Setting the identifier property of a newly created UIBarButtonItem programatically" or something similar.
Senseful
I'm sorry you stumbled upon my solution and it didn't quite meet your expectations. At the point of asking the question I was looking for a way to, in fact, change it. The solution worked for me - if it didn't for you then I'm sorry.
rein