How To Make IBAction Happen the 2nd Time Button Is Pressed

Discussion in 'iOS Programming' started by mandude, Dec 14, 2009.

  1. macrumors member

    Joined:
    Nov 19, 2009
    #1
    hi i have a simple UIButton named "button" with the IBAction "show" connected to it. I want it to be that when the user taps this button, nothing happens, but when the user taps it one more time, then the label magically appears. The user may tap the button once, and an hour later tap it again, and the label will only appear when the user taps the button "button" the second time. Here's the code:



    h. file:

    @interface PlayingCampeignViewController : UIViewController {

    UILabel *label;
    UIButton *button;
    NSUInteger *number;
    }

    @property (nonatomic, retain) IBOutlet UILabel *label;
    @property (nonatomic, retain) IBOutlet UIButton *button;
    -(IBAction)show;
    @end

    m. file:

    -(void)viewDidLoad {
    number = 0;
    }

    -(IBAction)show {
    number = number + 1;
    if (number == 2) {
    label.hidden = NO;
    }
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Are you uaecacher in disguise?

    Would you use the code tags?

    What's the question?

    Change this

    Code:
    NSUInteger *number;
    to this

    Code:
    NSUInteger number;
     
  3. thread starter macrumors member

    Joined:
    Nov 19, 2009
    #3
    hey thanks for the response... and ya i did that yet instead of my error before it now quits the first time i press the UIButton : P any more help and i would love you.
     
  4. thread starter macrumors member

    Joined:
    Nov 19, 2009

Share This Page