Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing right bar button item from navigation item

I have added a right bar button item in my navigation item and want to remove this on some condition. This is what I am doing:

self.navigationItem.rightBarButtonItem = nil; 

But not getting the desired behavior.

I want to hide it but do not find any method for it.

like image 797
Abhinav Avatar asked May 23 '11 22:05

Abhinav


People also ask

How do I hide items in navigation bar?

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.

What is bar button item?

A specialized button for placement on a toolbar, navigation bar, or shortcuts bar.

How do I hide UIBarButtonItem?

There is no way to "hide" a UIBarButtonItem you must remove it from the superView and add it back when you want to display it again. This is actually not true - the method described by Max works well.


1 Answers

What you're doing should work. I've done that lots of times. Are you sure you're removing the button from the correct navigation item? Is self the currently displayed UIViewController?

like image 198
Erik B Avatar answered Sep 30 '22 10:09

Erik B