I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options.
Unfortunately, the following doesn't work:
NO GOOD: self.navigationItem.rightBarButtonItem.hidden = YES; // FOO CODE
Is there a way?
I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options.
Unfortunately, the following doesn't work:
NO GOOD: self.navigationItem.rightBarButtonItem.hidden = YES; // FOO CODE
Is there a way?
Show:
Hide:
You can even animate its showing/hiding
For Swift 3
Set reference to nil:
Also be sure to call this in the controller currently shown by the navController, not for the navController itself.
In swift 4 I has a trick to show / hide right or left button:
Step 1: Create a IBOutlet button in view controller:
Step 2: Create Hide button function:
Step 3: Create Show button function:
Step 4: Just call the functions that you want, use
hideNavigationButton()
to hide, andshowNavigationButton()
to show the button.Regards!
Show:
Hide:
My solution: