resting
resting

Reputation: 17467

Hide a UIbutton when another UIbutton is pressed

I have a record button, which when pressed, I want to hide the instructions button.

Here's the code for the record button:

// Create custom overlay
// Create instruction/record button
// Add instruction/record button to custom overlay
[_videoRecordBtn addTarget:self action:@selector(startVideoRecord:) forControlEvents:UIControlEventTouchUpInside];

So in startVideoRecord I should have something like:

-(IBAction)startVideoRecord:(id)sender{
    [_instru setHidden:YES];
    // start recording...
}

But I have no idea how to pass the _instru button over to startVideoRecord.

Upvotes: 0

Views: 85

Answers (2)

Sumit Mundra
Sumit Mundra

Reputation: 3901

You can do this by 2 way..

1 way - > you set the tag of instructions button.

and use this

-(IBAction)startVideoRecord:(id)sender{

UIButton *instruBtn = (UIButton*)[self.view viewWithTag:your button tag];


instruBtn.hidden = YES;

// start recording...
}

2nd Way - > you make property for your instructions button and use like this

  -(IBAction)startVideoRecord:(id)sender{

    self.instruBtn.hidden = YES;

    // start recording...
    }

Upvotes: 1

JoeFryer
JoeFryer

Reputation: 2751

Add a property to your ViewController to keep a reference to your instructionsButton:

@property (nonatomic, strong) UIButton *instructionsButton;

When you create your instructionsButton, assign it to this property.

Then you can access the button via this property anywhere in your ViewController with self. instructionsButton.

So, your action method would be like:

-(IBAction)startVideoRecord:(id)sender{
    self.instructionsButton.hidden = YES;
    // start recording...
}

Upvotes: 1

Related Questions