I know this should be very simple, but since I really searched here and on Google without making my code work, I will ask. Yes, I checked related questions and they do not work ...
I just want to change the button image when clicked.
This is my header file:
And my implementation file:
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self.myButton setImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal]; [self.myButton setImage:[UIImage imageNamed:@"selected.png"] forState:UIControlStateSelected]; } @end
The button is built and connected in Main.storyBoard, and I also tried to do this in the attribute inspector, but none of them work!

Note that I am not looking for how to make the selected state, but the selected one.
source share