Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 2nd, 2012  |  syntax: None  |  size: 2.03 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to use if else conditon on button press based on image of button?
  2. if([UIImage imageNamed:@"checkbox_ticked.png"])
  3.     {
  4.         isActiveStr=[arrayPickerData objectAtIndex:17];
  5.         NSLog(@" is active value is %@ ",isActiveStr);
  6.         isActiveStr=nil;
  7.  
  8.     }
  9.     else
  10.     {
  11.         NSLog(@"no vlaue send");
  12.         isActiveStr=[[NSMutableString alloc]initWithString:@"1"];
  13.         NSLog(@" is active value %@",isActiveStr);
  14.     }
  15.        
  16. BOOL checked;
  17.        
  18. - (void)onButtonTapped:(UIButton *)button {
  19.  
  20.     checked = !checked;
  21.     ...
  22. }
  23.        
  24. if (checked) {
  25.  
  26.     // The button is checked
  27.  
  28. } else {
  29.  
  30.      // The button is not checked
  31. }
  32.        
  33. if ([[myButton imageForState:UIControlStateNormal] isEqual:[UIImage    imageNamed:@"checkbox_ticked.png"]]) {
  34. ...
  35.        
  36. if(!btnCheckbox.selected)
  37.     {
  38.         [btnCheckbox setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"check-out_h" ofType:@"png"]] forState:UIControlStateNormal];
  39.         btnCheckbox.selected=YES;
  40.     }
  41.     else {
  42.         [btnCheckbox setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"check-out" ofType:@"png"]] forState:UIControlStateNormal];
  43.         btnCheckbox.selected=NO;
  44.     }
  45.        
  46. -(void)checkBoxIsHideNationWideClicked
  47. {
  48.     NSLog(@"nation wide button clicked");
  49.  
  50.     mybtn.selected=!mybtn.selected;
  51.     defaultsCheckBox=[NSUserDefaults standardUserDefaults];
  52.  
  53.     if (mybtn.selected)
  54.     {
  55.         [defaultsCheckBox setValue:@"One" forKey:@"CheckBox"];
  56.  
  57.         NSLog(@" is active value is %@ is fetched succesfuly",hideNationWideStr);
  58.         [CommonVar setHideNationwideData:hideNationWideStr];
  59.         NSLog(@" is active value send to cmmon class %@ sent succesfuly",hideNationWideStr);
  60.     }
  61.     else
  62.     {
  63.         [defaultsCheckBox setValue:@"Two" forKey:@"CheckBox"];
  64.         NSLog(@"no vlaue send");
  65.         hideNationWideStr=[[NSMutableString alloc]initWithString:@"1"];
  66.         [CommonVar setHideNationwideData:hideNationWideStr];
  67.         NSLog(@" is active value send to cmmon class %@ sent succesfuly",hideNationWideStr);
  68.     }
  69. }