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

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 8  |  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. (IBAction)button to label output
  2. -(IBAction)buttonAction: (id)sender
  3. {
  4.  UIButton *but=(UIButton *)sender;
  5.  if(but.tag==1)
  6.  {
  7.    val++;
  8.    [label setText:[NSString stringWithFormat:"%@"],val];
  9.  }
  10.  else
  11.  {
  12.    val--;
  13.    [label setText:[NSString stringWithFormat:"%@"],val];
  14.  }
  15. }
  16.        
  17. @interface RootViewController :     UIViewController<> {
  18. IBOutlet UIButton *incrBtn;
  19. IBOutlet UIButton *decrBtn;
  20. IBOutlet UILabel *label;
  21. NSInteger counter;
  22.  
  23. }
  24.  
  25. -(IBAction)incr;
  26. -(IBAction)decr;
  27.        
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. counter=0;
  31. label.text=[NSString stringWithFormat:@"%d",counter];
  32. }
  33.  
  34. -(IBAction)incr{
  35. counter++;
  36. label.text=[NSString stringWithFormat:@"%d",counter];
  37.  
  38.  
  39. }
  40.  
  41. -(IBAction)decr{
  42. counter--;
  43. label.text=[NSString stringWithFormat:@"%d",counter];
  44.  
  45.  
  46. }