
Untitled
By: a guest on
Jun 2nd, 2012 | syntax:
None | size: 2.03 KB | hits: 26 | expires: Never
how to use if else conditon on button press based on image of button?
if([UIImage imageNamed:@"checkbox_ticked.png"])
{
isActiveStr=[arrayPickerData objectAtIndex:17];
NSLog(@" is active value is %@ ",isActiveStr);
isActiveStr=nil;
}
else
{
NSLog(@"no vlaue send");
isActiveStr=[[NSMutableString alloc]initWithString:@"1"];
NSLog(@" is active value %@",isActiveStr);
}
BOOL checked;
- (void)onButtonTapped:(UIButton *)button {
checked = !checked;
...
}
if (checked) {
// The button is checked
} else {
// The button is not checked
}
if ([[myButton imageForState:UIControlStateNormal] isEqual:[UIImage imageNamed:@"checkbox_ticked.png"]]) {
...
if(!btnCheckbox.selected)
{
[btnCheckbox setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"check-out_h" ofType:@"png"]] forState:UIControlStateNormal];
btnCheckbox.selected=YES;
}
else {
[btnCheckbox setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"check-out" ofType:@"png"]] forState:UIControlStateNormal];
btnCheckbox.selected=NO;
}
-(void)checkBoxIsHideNationWideClicked
{
NSLog(@"nation wide button clicked");
mybtn.selected=!mybtn.selected;
defaultsCheckBox=[NSUserDefaults standardUserDefaults];
if (mybtn.selected)
{
[defaultsCheckBox setValue:@"One" forKey:@"CheckBox"];
NSLog(@" is active value is %@ is fetched succesfuly",hideNationWideStr);
[CommonVar setHideNationwideData:hideNationWideStr];
NSLog(@" is active value send to cmmon class %@ sent succesfuly",hideNationWideStr);
}
else
{
[defaultsCheckBox setValue:@"Two" forKey:@"CheckBox"];
NSLog(@"no vlaue send");
hideNationWideStr=[[NSMutableString alloc]initWithString:@"1"];
[CommonVar setHideNationwideData:hideNationWideStr];
NSLog(@" is active value send to cmmon class %@ sent succesfuly",hideNationWideStr);
}
}