Search code examples
uibuttonibaction

How can I hide and unhide buttons with the same UIButton?


I have to hide some buttons when I tap a button, and unhide them when I touch the button again.
This is what I have:

- (IBAction)hideButtons {
    backbutton.hidden = YES; 
    nextbutton.hidden = YES;
    resetbutton.hidden = YES;
}

and

- (IBAction)showButtons {
    backbutton.hidden = NO; 
    nextbutton.hidden = NO;
    resetbutton.hidden = NO;
}

How can I do this with one button? At first the buttons should be unhidden.


Solution

  • Just use this: (Works if all buttons are in the same state first):

    backbutton.hidden=!backbutton.hidden; 
    nextbutton.hidden=!nextbutton.hidden;
    resetbutton.hidden=!resetbutton.hidden;
    

    Hope this helps