Title: UIButton changes states when being pressed
Tags: ios;objective-c;uibutton
Question: I have an UIButton configured with two states, default and selected, for different text and background, the set up is done on Interface Builder. The weird thing is when the button is in selected state, and the button is pressed, it automatically changes to default state. After the button is released, it changes back to selected state. Is there way to disable roll-back-to-default behavior?
Forgot to mention that, the type is custom.
Update
tried the following code in viewDidLoad
[self.button setTitle:@"default" forState:UIControlStateNormal];
[self.button setTitle:@"selected" forState:UIControlStateSelected];
[self.button setTitle:@"highlighted" forState:UIControlStateHighlighted];
[self.button setSelected:YES];
The button shows default when pressed.
Comment: No it went to the default state.

Comment: it doesn't go back to the default state. it goes to the highlighted state

Comment: I set the button title for different states in viewDidLoad, it shows the default state content when pressed. Please see my update for the sample code.

Here is the accepted answer: Selected state and Highlighted state are not mutually exclusive. When you press a selected UIButton, it gets into a selected AND highlighted state.
I don't think there's a way to set that in the IB, but you can do this in code:
[button setImage:[UIImage imageNamed:@"some_image"] forState:UIControlStateSelected | UIControlStateHighlighted];


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:04/21/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><objective-c><uibutton>', 'Title': 'UIButton changes states when being pressed', 'ViewCount': 2674, 'id': 23207067, 'user_AboutMe': '<p>Go Ducks</p>\n', 'user_AccountId': 353742.0, 'user_DisplayName': 'Dino Tw', 'user_Reputation': 2991.0, 'user_Views': 344.0, 'user_id': 691626.0}}