UINavigation Controller hiding navbar - ios

using xcode 4.2 and iOS 5 and have nav bar on root controller and four other views (inc UITable view) all i want is to hide nav bar in first root view controller and show in all other views...
Tried following
[self.navigationController setNavigationBarHidden:YES animated:animated];
No luck any ideas?

Use this code in your root controller (or all of your view controllers that you want to have a hidden navigation bar. see [1] though) in order to hide/show the navigation bar according to what you are aiming at:
- (void)viewDidLoad {
...
[self.navigationController setNavigationBarHidden:YES animated:NO];
...
}
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
....
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
...
}
This is just a possible solution. You could well leave viewWillDisappear undefined in your non-root controllers and define viewWillAppear in your root controller... as you see it most convenient for you.
[1] Hiding the navigation bar in anything but the root controller makes it possible to get stuck in the middle of your navigation hierarchy. Also it is against intuitive navigation in an iOS app to suddenly hide the navigation bar for anything else than the root view.)

You can hide this by using this code
self.navigationController.navigationBar.hidden = YES;
Use this code in view did load

Related

uinaviationcontroller pop animation become weird when status bar was hidden

as picture : when the white controller in popping out with a interactive pop gesture , the red controller (which make the status bar hide) will show, and during the animation : the navigation bar seems to move up , and the controller's view is still in its position (not move up with navigation bar) ,so the view seems divided into two pieces in the pop out animation . how to fix it ?
In the first controller,add this code.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

Navigation bar height changing on hide and unhide

In my application I have to show one screen with navigation bar and then by pushing another controller with no navigation bar.
When I come back I again want to show the navigation bar. But, my navigation bar is not visible with complete height.
I set the navigation bar with no translucent, and style opaque.
can you help me anyone.
this will hide and show navigation bar perfectly:
in first view controller implement:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
in pushed view controller:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
Show some code...
or try showing the navigation bar from the view controller you're coming back from just before you tell it to go back... Should avoid the issue. But suspect you're doing something else wrong.
Use this method:
In view controller where you want to hide navigation bar add the below code in viewWillAppear
[navigationController setNavigationBarHidden:YES];
So, if you are in some view controller:
In view controller where you want to show navigation bar add the below code in viewWillAppear
[self.navigationController setNavigationBarHidden:NO];

I have view controllers in a navigation controller hierarchy, but only want the navigation bar on the first view controller - how do I do this?

I have a main view controller that lists a bunch of items, and when they tap on one of the items it segues them to the next view. However, in the next view, I don't want the navigation bar to be there, I only want it in the first view (I'm using a UIToolBar for the navigation bar, kind of like in iBooks).
How exactly do I go about achieving this? If I remove the main view controller from the navigation controller completely (unembedding, effectively) I can implement the nav bars selectively, but this solution doesn't allow segues, so it's no good.
My other solution was to call self.navigationController.navigationBarHidden = YES; in viewDidAppear for the second view, but with this, the UIToolBar that I added in my storyboard is pushed under the navigation bar that hasn't been hidden yet, and then when it does get hidden, it disappears and the UIToolBar "falls down", which is a pretty gross effect to the user.
What would be the best way to go about getting this effect?
The best way to do that is the following. In you viewWillAppear: in the first (rootViewController) of your UINavigationController, you set:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
and then in you viewWillDisappear, you the the opposite:
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
This way should work without nothing 'ugly' happening to the user.

Show UINavigationBar

Here's the deal... I can't get the UINavigation bar to appear on one of my views. I have the whole thing in a NavigationViewController in IB and turned of the navigation bar though IB because I don't want it in most of my app but when I try to show the navigation bar via code, it doesn't show up.
here's the code I used to try to get the nav bar to show up... but didn't work:
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setNavigationBarHidden:NO];
self.navigationController.navigationBarHidden = NO;
self.navigationController.navigationBar.hidden = NO;
Any help will be greatly appreciated
respectfully,
Matt
The code you write should only work inside of one of UINavigationController's controllers, not views.
So, if you call it from your view, you should replace self with controller name,in which this view is placed.

Set navigation bar hidden, depending on how the view controller appeared

I have a tab bar with a navigation controller in one of the tabs. Currently the root view of the navigation controller doesnt have the nav bar showing and animates nicely into the subviews by
- (void)viewDidLoad {
...
[self.navigationController setNavigationBarHidden:YES animated:NO];
...
}
and
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
But of course changing tabs initiates the viewWillAppear function and so as I go back to the root view the navigation bar slides away, rather than just not being there.
Is there a way that I can hide the nav bar on the root view without animating it except for when appearing from a subview on the navigation stack?
The (BOOL)animated parameter on viewWillAppear:animated. When changing Tabs, it will come as NO, since the animation is immediate. On the other hand, if it's being pushed or popped from the navigation stack with animated:YES, then it will come as YES.
Although this looks like a hack, it's the correct way: you don't need to figure out who was the caller, instead, focus on the fact that if your view controller will appear animated, you have time to do your own animations, if not, screw it, show (or in this case, hide) everything immediately.
Try showing/hiding the bar in the UINavigationController's delegate's navigationController:willShowViewController:animated: method, depending on whether the view controller being shown is your root view controller.
What if you set a boolean variable in your application delegate and in set that boolean accordingly in subviews as 0 and in other views as 1. And in your viewwillappear, according to your variable's value, you can set the animation.

Resources