iOS / iPhone- Hiding one button when another is clicked

Jack BeNimble picture Jack BeNimble · Oct 18, 2011 · Viewed 20.2k times · Source

I have a settings view in my app which has a couple of buttons (actually UISwitches). If the "off" setting on one of the switches is selected, I'd like to hide the second switch immediately. Can this be done?

Answer

Gabriel picture Gabriel · Oct 18, 2011
IBOutlet UIButton *btn1;
IBOutlet UIButton *btn2;

write the above 2 lines in your .h file and set the outlets with XIB.

Now create a method called hideButton

-(IBAction)hideButton
{
       btn1.hidden = YES;
}

in XIB attach this method with btn2. So now when you click on btn2 it will hide btn1.