I have added a BarButton
item to the left of the nav.bar
through Interface Builder and in the code I want this only to show in my table view's edit mode. But I didn't find any hidden property to set the leftBarButtonItem
(like: self.navigationItem.leftBarButtonItem.hidden = YES
).
I can only set enabled
property. Anybody know how to control the hide and show property of the leftBarButtonItem
, please help.
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.
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.
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. Let's create a project, add 2 view controller and Embed them in navigation controller.
This works I tried it myself
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = YES;
I'm pretty sure the only way to "hide" it is to nil it out.
self.navigationItem.leftBarButtonItem = nil;
Though it's not a perfect answer to your question, since that basically gets rid of your button instead of hiding it. You'll either have to recreate it or keep your original button around and simply set the leftBarButtonItem back to your UIBarButtonItem.
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