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.
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.
A specialized button for placement on a toolbar, navigation bar, or shortcuts bar.
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.
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
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With