I have a hierachy of view controllers inside a navigation controller and I for the root view controller I set the "hidden" property of the navigation controller bar to YES. All of its children have the "hidden" property set to NO. The problem is that I don't know where is the best place to hide the bar, because when I press the "back" button to return to the root view controller I can see how the navigation bar dissapears and the root view controller view's resizing and this is not a good user experience.
Where did you put your hide/unhide calls? The best place will probably be in viewWillAppear, such as in this post.
Something like:
if (![self.navigationController isNavigationBarHidden])
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
Related
I have a view which is located inside a navigation controller which is inside a tab bar controller like this:
Tab Bar Controller
Navigation Controller
View Controller
I have designed the layout of the View Controller in a xib. When I click the tab for the view the view is displayed correct. The view will be place within the navigation bar and the tab bar - it will not overflow.
But when I want to open the view programmatically - not via the tab bar - but with pushViewController [1] the view expands all the way to the outer bounds of the frame. The view will be over the status bar and below the tab bar.
I cannot find a solution to this. Does anybody have any ideas how to solve this?
[1]
[self.navigationController pushViewController:[[MyViewController alloc]
initWithStringAddress:"someIdUsedInController" animated:YES];
I am trying to setup a Model View Controller to have a Navigation Bar just in the storyboard.
I have setup a segue from one view controller to another and marked it as Model.
I have changed the Model VC to have Top Bar : Translucent Navigation Bar.
I call the segue by name with the following:
[self performSegueWithIdentifier:#"testModel" sender:self];
When the model view controller shows up there is no Navigation Bar. Am I missing something that should make this show.
The Model View Controller is not actually in a Navigation Controller stack and shouldn't be as there is no movement other than dismiss from this Model View Controller. I am just trying to use the Navigation Bar to show a title for the model VC.
When you changed your view controller to "Top Bar : Translucent Navigation Bar.", that is under "Simulated Metrics". Changing that value tells Xcode that the view controller will have a navigation bar, it does not actually create a navigation bar. I suggest you either
Embed your view controller in a navigation controller (there is no rule that says you have to push anything from your navigation controller, and you might decide to add features in the future)
Use a toolbar instead of a navigation bar
Just use a label if all you want is a title on your view controller.
I know using below statement I can hide navigation bar.
[self.navigationController setNavigationBarHidden:YES animated:NO];
But I want to do this for whole app.
I don't want to write this statement in all files.
So any idea how can I hide navigation bar for whole project?
If you have used Storyboards, then setting the Navigation Bar to None in the Navigation Controller, and ensuring that the top bar is set to 'Inferred' for all view controllers contained within the navigation controller will ensure that the navigation bar will be hidden for all view controllers in the navigation controller.
You can also use
self.navController.navigationBar.hidden = YES;
In my storyboard I have a view with a segue into a new view that's embedded into a Navigation Controller (so the segue points to the navigation controller). I have the segue set to a Modal transition, however when the new view is animating up, it contains the standard blue navigation bar above the view (which then animates out of view).
Here's what it looks like mid segue: http://i.imgur.com/3eqAQ.png
How do I make it so the modal view animates up but without the navigation bar?
I have tried hiding the navigation bar in the embedded view's init, viewWillAppear, and vieWillLoad methods and that doesn't work.
I event went so far as to create a custom subclass of UINavigationController and set the navigation controller in the storyboard to it.
Thanks!
This may sound pretty simple, but have you tried hiding the navigation bar immediately before the modal segue starts? I had this problem when presenting a modal view controller and adding a [self.navigationController setNavigationBarHidden:YES] immediately before the presentation did the trick for me.
I had almost the same problem, but I wanted to get a navigation bar for my modal transition, as it was always hidden.
There may be two ways for you to remove the navigation bar:
Make sure that your view controller is not embed in a navigation controller, as it would put one by default
Check the "Top Bar" attribute of your previous controller in the workflow and work with none/inferred values depending on your storyboard.
Regards
I have application with 2 tab bars. In second tab bar I have navigation controller. I want to change this navigation controller to another navigation controller when "Change" button is pressed. How can I do that? Please help me.
Thanks
You'd have to replace the View Controller in the TabBar using the viewControllers property of UITabBarController or setViewControllers:animated:if you want to add some animation.
But maybe you should think of having 2 views in a controller of yours and hide/show them when you click a button, maybe even pushing/popping view controllers without animation (pushViewController:yourController animated:NO) on the navigation stack of your navigation controller and just hide the back button (self.navigationItem.hidesBackButton = YES)