Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the rightNavigationBar button item in iPhone

I want to hide the rightNavigationBarItem when my ViewController loads. How is it possible? I have tried this code but it is not working.

self.navigationItem.rightBarButtonItem = nil;
like image 967
Rani Avatar asked May 18 '11 07:05

Rani


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 turn off the navigation button on my iPhone?

Question: Q: How to get rid of home button on iPhone screenGo to Settings > Accessibility > Touch, then select AssistiveTouch to turn it off. That is called Assistive Touch.

How do I disable navigation items?

The option to disable Navigation bar can be set via Settings > Navigation Bar. When disabled, Home, Back, and Recents buttons will be removed from the screen, allowing more room for app use.


2 Answers

In Xcode 4. using these won't work;

self.navigationItem.leftBarButtonItem.enabled=NO;
self.navigationItem.leftBarButtonItem=nil;
self.navigationController.navigationBar.backItem.hidesBackButton=YES;
[self.navigationItem.leftBarButtonItem release];

I'm actually interested why you mention rightBarButtonItem? When you navigate, its the leftBarButtonItem that changes.

What Does Work;

1) self.title =@""; nulling the title of the screen, when the navigation controller pushes a detail view onto the stack, no back button is created.

2) replacing the leftBarButtonItem with something else changes the button, but doesn't solve your problem.

3) An alternative. Hide the navigation bar; [self.navigationController setNavigationBarHidden:YES animated:YES];

like image 142
Bill Thompson Avatar answered Sep 22 '22 13:09

Bill Thompson


Hi it does not hide but make it disable

 self.navigationItem.rightBarButtonItem.enabled = NO;
like image 26
Csabi Avatar answered Sep 22 '22 13:09

Csabi