Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the rightBarButtonItem of a navigation controller

Does anyone know how to hide a rightBarButtonItem of a UINavigationController? In my application, I have an edit button as a rightBarButtonItem of a UINavigationController. I want to hide this ? UIBarButton` when some operations are done.

like image 907
user347161 Avatar asked Jun 15 '10 05:06

user347161


People also ask

How do I hide Rightbarbuttonitem in Swift?

In swift 4 I has a trick to show / hide right or left button: Step 1: Create a IBOutlet button in view controller: @IBOutlet var navigationItemButton: UIBarButtonItem! Step 4: Just call the functions that you want, use hideNavigationButton() to hide, and showNavigationButton() to show the button.

How do I hide the navigation bar button?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How to hide navigation back button in iOS Swift?

Basic Swift Code for iOS Apps To hide the back button on navigation bar we'll have to either set the navigation button as nil and then hide it or hide it directly.


1 Answers

To Hide the right button: self.navigationItem.rightBarButtonItem = nil;

Now, to show it:

  1. If you setup the right button in your view controller by assigning it to self.editButtonItem then simply assign it again in order to show it:

    self.navigationItem.rightBarButtonItem = self.editButtonItem;

  2. If you setup the right button in your view controller by allocating and initing a UIBarButtonItem, then simply keep a reference to the UIBarButtonItem in your view controller, and assign it again when you need to show it.

like image 104
MyCSharpCorner Avatar answered Oct 01 '22 02:10

MyCSharpCorner