Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the uibarbutton item of a navigation bar

i am unzipping a file on background thread and i am calling HomeViewController on main thread.in this view controller i have a UIBarButtonItem on UINavigationBar. if i click this button it goes to StoryViewController and the unzipped data is used there. so i want to show the Home view Controller though the unzipping process is not completed, for that i have to hide the button on the navigation bar when the unzipping starts on backround thread and after completion of the upzipping again i have to show the button on navigation bar. i am calling the methods of homeViewController to hide and show.. What i have to write in those methods..? i mean how to hide and show the uiBarButtonItem on UINavigationBar....?

Thanks....

like image 966
rockey Avatar asked Nov 11 '10 21:11

rockey


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.

How do I hide Uibarbuttonitem in swift 5?

Since UIBarButtonItems do not have a “hidden” property, we can't just set this to yes and it'll disappear. Instead, we can set them to nil.


1 Answers

Once you have created your UIBarButtonItem say "myButton", you can add/remove it to your navigation controller using in your view Controller:

if(show)
    self.navigationItem.leftBarButtonItem = myButton;
else
    self.navigationItem.leftBarButtonItem = nil;
like image 108
Romain Avatar answered Nov 15 '22 06:11

Romain