I’m using the code in this answer to generate a grid of buttons.
When a button is clicked I want to change the button image. So I need to do something like:
- (void)buttonPressed:(id)sender {
[toggleButton setImage:[UIImage imageNamed:toggleIsOn @"on.png"]
forState:UIControlStateNormal];
}
But I don’t know how to assign toggleButton to the right button from the UI. I don’t have an outlet for every button. Any ideas how I can do this?
If you are changing the same button that has been pressed, this should work:
This is because
senderis the button that has been pressed.