tags:

views:

119

answers:

1

I have a UIButton, and I'd like to update it's title. But I'd rather not have to always do it each and ever state like the following:

[myButton setTitle:@"Play" forState:UIControlStateNormal];

[myButton setTitle:@"Play" forState:UIControlStateHighlighted];

[myButton setTitle:@"Play" forState:UIControlStateSelected];

Is there a better way?

+1  A: 

According to the documentation you should only need to call:

[myButton setTitle:@"Play" forState:UIControlStateNormal];

The UIButton docs explain why:

In general, if a property is not specified for a state, the default is to use the UIControlStateNormal value. If the value for UIControlStateNormal is not set, then the property defaults to a system value. Therefore, at a minimum, you should set the value for the normal state.

Namely, that if you only set the normal value the other states will refer to it when being set.

fbrereto