iPhone: Set the title of a UIButton with a single method invocation?

Posted by Greg Maletic on Stack Overflow See other posts from Stack Overflow or by Greg Maletic
Published on 2010-03-19T18:01:24Z Indexed on 2010/04/15 0:13 UTC
Read the original article Hit count: 495

Filed under:
|

I'd like to set the title of a UIButton via code. I find myself having to call -[UIButton setTitle:forState:] for UIControlStateNormal, UIControlStateHighlighted, UIControlStateDisabled, UIControlStateSelected. And that doesn't even take into account all of the combinations of these states together.

Needless to say, this is tiresome. Is there a single call I can make that will set one string as the title for all of the states? (Since, I assume that in 95% of the cases, that's the desired behavior?)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uibutton