Angad
Angad

Reputation: 84

Hide an iOS button when it is pressed

I have defined a button in my Storyboard. I have then defined it in my .h file as an IBAction, and connected it to the button from the storyboard.

I want it to be hidden by default, and also when I tap it once, it should hide itself. I'm not having any luck trying to hide it.

This is what my code looks like right now. There's an error thrown:

Property hidden not found on object of type CounterViewController

- (IBAction)retry:(id)sender 
{
    self.hidden=TRUE;
}

Upvotes: 0

Views: 195

Answers (2)

Jiten Parmar
Jiten Parmar

Reputation: 164

You can also use following

- (IBAction)retry:(UIButton *)sender 
{
    sender.hidden=YES;
}

Upvotes: 1

Antonio MG
Antonio MG

Reputation: 20410

Try this:

 - (IBAction)retry:(id)sender {
     ((UIButton *)sender).hidden=YES;
 }

Upvotes: 5

Related Questions