Hiding a UIBarButtonItem
Hiding a UIBarButtonItem, there should really be a hide function :S It’s pretty simple to set a button (UIButton) to be hidden on the iPhone:
.h file: IBOutlet UIButton *myButton;
.m file: if(myButton.hidden == NO) [myButton setHidden:YES];
So one would expect the UIBarButtonItem to be the same right? Wrong! Why I hear you shout?… I don’t have a clue…
In case you don’t know or remember what the UIBarButtonItem its the buttons stored inside the footer/header button container.

Both "Your Account" and "Home" are UIBarButtonItems
The best solution for this I’ve found is the following:
.h file: IBOutlet UIBarButtonItem *myBarButton;
To hide .m file:
accountCloseButton.title = @”";
[ myBarButton setStyle:UIBarButtonItemStylePlain];
[ myBarButton setEnabled:FALSE];
To show .m file:
accountCloseButton.title = @”My Button”;
[myBarButton setStyle:UIBarButtonItemStyleBordered];
[myBarButton setEnabled:TRUE];
If you know if there is a reason for this or know of a better solution please post!



No Comments Comments Feed
Add a Comment