I am using UIButton with xib backgroundImage is check_box_off.png, while clicking the
atmbtn backgroundImage change to check_box_on.png meanwhile NSLog printing yesString and again clicking atmbtn there is no change in backgroundImage same check_box_on.png meanwhile NSLog Printing same yesString only.. again and again clinking the atmbutton same only happening..
- (IBAction)atmAction:(id)sender{
if( [atmbtn backgroundImageForState:UIControlStateNormal] ==
[UIImage imageNamed:@"check_box_on.png"] ) {
[atmbtn setImage:[UIImage imageNamed:@"check_box_off.png"]
forState:UIControlStateNormal];
noString = @"No";
NSLog(@"atm=%@",noString);
} else if( [atmbtn backgroundImageForState:UIControlStateNormal] ==
[UIImage imageNamed:@"check_box_off.png"]) {
[atmbtn setImage:[UIImage imageNamed:@"check_box_on.png"]
forState:UIControlStateNormal];
yesString = @"Yes";
NSLog(@"atm = %@",yesString);
}
}
output:
NSLog Print:
atm=Yes
atm=Yes
atm=Yes
how Could I resolve this? Please Share your Ideas.
use this: