I know this question is asked many a times,and i am also implementing the same funda for chanding the title of the uibutton i guess.
Let me clarify my problem first. I have one uibutton named btnType, on clicking of what one picker pops up and after selecting one value,i am hitting done button to hide the picker and at the same time i am changing the the title of the uibutton with code
[btnType setTitle:btnTitle forState:UIControlEventTouchUpInside];
[btnType setTitleColor:[UIColor redColor] forState:UIControlEventAllEvents];
toolBar.hidden = FALSE;
dateTypePicker.hidden = FALSE;
@interface AddSettingPage : UIViewController<UITextFieldDelegate>
IBOutlet UIButton *btnType;
@property (nonatomic, retain) IBOutlet UIButton *btnType;
[yourButton setTitle:@"your title" forState:UIControlStateNormal]; [yourButton setTitle:@"your title" forState:UIControlStateSelected]; [yourButton setTitle:@"your title" forState:UIControlStateHighlighted];
when the picker is dismissed, the button (which was the control that hold focus) will be in the selected state (or the highlighted .. check it out).
and stop using
UIControlEventTouchUpInside in the
forState: parameter. it is not a state, it is an event. you are passing an event identifier instead of a state identifier