Q:

set UIButton's image in interface builder for differen state

I am facing very strange issue.
In interface builder I am trying to set images for "normal" state config and for "selected" state config. but by clicking the button my image is not getting changed.
even I write the code in viewDidLoad method.
[btnCheckBoxMale setImage:[UIImage imageNamed:@"blankcheckbox.png"] forState:UIControlStateNormal];
    [btnCheckBoxMale setImage:[UIImage imageNamed:@"checkbox.png"] forState:UIControlStateSelected];

but my images are not getting changed on cliking on it
can anyboday say what is the problem?

A:

Set the image to different states in interface builder instead of setting it in code. Please see the screenshot for how to set it. Try this & if you are facing any problem then ask me.

A:

It will work if you set manually in button action:
btnCheckBoxMale.selected = YES;

Because by default UIButton has only two states - Normal and Highlighted. And other states like selected and disabled you have to control manually.

A:

just set selected when you call the method on button click event.. for example..
-(IBAction) btnCheckBoxMale_Clicked:(id)sender{
    [btnCheckBoxMale setSelected:YES];
}

