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];
}
Related
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'm navigating from a UITableView to a normal ViewController.
I'm displaying the navigationBar like this:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
The first time I hit a row in the UITableView, the navigationBar shows up, but the second time it remains hidden. This is not expected behavior, since viewWillAppear should work every time the view shows up.
Why is the navigationBar hidden when viewing the view for the second time?
This is because you are hiding navigation bar in viewWillAppear of table view. So it will hidden for other pushed view controllers. So in order to get rid of that you have to un hide navigation bar in view did disappear of table view.So it will work in desired manner.
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
}
I use following method to disable the Navigation bar throughout the app:
[navcontroller setNavigationBarHidden:YES animated:YES];
But is it possible to disable it only for one ViewController?
Certainly. Whenever you enter a viewcontroller, you can enable or disable for that viewcontroller (just call [[self navigationController] setNavigationBarHidden:YES animated:YES] during viewWillAppear
The nicest solution I have found is to do the following in the first view controller.
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
This will cause the navigation bar to animate in from the left (together with the next view) when you push the next UIViewController on the stack, and animate away to the left (together with the old view), when you press the back button on the UINavigationBar.
Please note also that these are not delegate methods, you are overriding UIViewController's implementation of these methods, and according to the documentation you must call the super's implementation somewhere in your implementation.
Hopefully this will resolve your problem.
I am using UINavigationController to direct some view controllers.In some view controller, I don't want to use UINavigationBar, but in some others i may use. Now I am try to pop one view controller using UINavigationBar to its previous one which hide UINavigationBar. But when poped, there is one wired black space under screen. After you rotate the screen, the space will disappear.
the normal view controller A should be like this:
when press the text button, a view controller B will be pushed, which is as followings:
when click back button on the navigation bar. A will come out.but there is a black space at the bottom.
If rotate the screen, the space will disappear. And also in A's - (void)viewWillAppear:(BOOL)animated method i hide the navigationbar and let the screen autorotate.
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}
whats wrong with this situation? Any help will be appreciated.
I add setNavigationBarHidden: method in the back button action method. it works. If i add this method in viewWillDisappear: method or others, it seems it doesn't work. The navigation bar will have effect on next appear view controller. which means, there will be a black space in the next view controller in the navigation stack.
Finally, i add a action method for the back button and setNavigationBarHidden:YES in the method, which is as follows:
- (void)backBtnClicked:(id)sender
{
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController setNavigationBarHidden:YES];
}
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