PDA

View Full Version : How To Make IBAction Happen the 2nd Time Button Is Pressed




mandude
Dec 14, 2009, 07:12 PM
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;
}



PhoneyDeveloper
Dec 14, 2009, 07:49 PM
Are you uaecacher in disguise?

Would you use the code tags?

What's the question?

Change this

NSUInteger *number;

to this

NSUInteger number;

mandude
Dec 14, 2009, 08:40 PM
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.

mandude
Dec 14, 2009, 08:41 PM
nevermind it works i love you.