I want to hide the bottom toolbar on a certain screen in my application, and IB seems to have an option for that which seems to preview as working correctly, but when I build and test the application the bottom toolbar is still there.
I know that I can use [self.navigationController setToolbarHidden:YES]; but my question is not how to do it using code, but how to get this to work through Interface Builder.
Here is a screenshot of what I am talking about. See on the right how I have selected Bottom Bar: None - this removes the bottom bar as previewed to the left. If I set it to inferred (instead of None) the bottom bar shows in the IB preview.
How do I get this to work correctly?
You can't set this in Interface Builder. If you notice the header of the section in IB where you can turn on/off these different bars, it says "simulated". These options are only there to help you visualize your UI in IB while designing it. They have absolutely no influence on the running app.
I couldn't do it in storyboard when you just want to hide toolbar in one view controller. If you want to hide it for all, you need to go to the navigation controller, and set the values in the storyboard. But this makes all of your view controllers to hide the toolbars. If you want to hide it for one view controller use this in that view controller:
-(void) viewWillAppear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: YES];
}
-(void) viewWillDisappear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: NO];
}
Enable "Hides Bottom Bar on Push" within the IB in case your ViewController is pushed onto a UINavigationController stack.
This should exactly do what you are asking for. As a bonus, the hiding and showing will be nicely animated by the system.
Related
I recently started using interface builder, the problem i'm facing right now is when i use the back button of navigation controller, my UI elements' y axis go up by roughly 20-30 px, is there some setting i've to use to avoid this problem ? And they go up only when i use pushViewController, when i use popViewController it loads the way i need.
Code i'm using for pushing:
examVC=[[ExampleClass alloc] initWithNibName:#"ExampleClass" bundle:nil];
[[self navigationController] pushViewController:examVC animated:YES];
I'm attaching the images with the question. Please note how label has gone down about 20-30 px.
Why does this happen? What am i doing wrong ?
Thanks for all the help.
Edit : changed the screens for better clarity
I'm using pushing code on the round rect button.
Screen 1:UI elements set in my IB
Screen 2: How it looks when pushed from previous view
Screen 3: How it looks when popped from the "Next View"
My home view controller had the navigation bar hidden, the screen i posted was the second view which comes after the home view. I wanted to hide navigation bar in the first view only, so i had used :
- (void)viewDidDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
It caused the problem because i was showing the navigation bar again in viewDidDisappear, so the view would load first then the navigation bar would be shown causing it to overlap.
So i put the same code in viewWillDisappear, which removed the issue. As navigation bar did load before loading of the next view. Now the view loads just like i designed it in interface builder.
Hey I don't know whether it will work for you or not but in your IB change top bar None to Navigation Bar
Then adjust your element accordingly and tun the code.
I tried all of the suggestions here and none of them worked. My UI elements were always lower when popping back to my original view controller. The only thing that fixed this for me was going into my nib file in Interface Builder and turning off Auto Layout.
When I push a view via my app's navigationController, it automatically puts a back button on the left side of the navigationBar. Is there any way I can just remove this? (I want to put my own buttons on the screen that will allow the view to be popped).
From the comments, you can hide the back button for a viewController by using its navigationItem property. (which is the UINavigationItem corresponding to that viewController in the stack of the navigationController. its how you control what shows up on the bar for specific view controllers (see Apple Doc here)).
To answer your question, set the navigationItem's hidesBackButton property to YES. Something like this probably called in your viewControllers viewDidLoad: or similar method.
myViewController.navigationItem.hidesBackButton = YES;
have you try with self.navigationItem.hidesBackButton=YES;?
If I wanted to do it, I'd hide the Navigation bar on push (non animated hide), add a toolbar, and add any custom stuff I want to the toolbar.
on popping the view controller, make sure to unhide the navigation bar. It'll work
I am creating a navigation base application. I need to display a tab bar too.
My mainWindow.xib contains:
UINavigationController,
UITabBarController.
UITabBarController has three UINavigationController with it.
On a condition-based algorithm, I am displaying the Navigation and the TabBar.
It's working well. The problem occurs when I want to move any inner view of TabBar: it shows navigationBar there (what I need) but it shows TabBar too. I want to remove the TabBar of all inner view. When I hide the tabbar it still occupy its space at the bottom of view. I had tried to reset frame of View and Window but nothing helped.
How can I hide tabBar and use its space in my view?
Is the logic I am using correct or not? If not, please tell how to correct it. If there is a tutorial it would be better.
You can try this:
yourInnerViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:yourInnerViewController animated:YES];
The answer is that you can't and trying to force it will break apple's HIG and they'll most probably reject your app.
The way I got around it was to use [self presentModalViewController:animated:] instead of [self.navigationController pushViewController:animated:].
I know its annoying, but a tab bar controller is there to switch between sections of your app. Therefore it provides functionality outside of the context of the navigation controllers within it and therefore cannot be hidden (properly) from inside one of those navigation controllers.
I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)
I have a small multiview app. It consists of a UITabBarController with a nav controller in each tab. What I want is to show a UIImageView when a user shakes the device. After I've implemented the loading of the UIImageView, I faced a problem-the image was only 2/3 of the screen because of the tab and nav bars. I managed to hide the nav bar but I'm still stuck with the tab bar. I tried many solutions such as [tabBar setHidden: YES]; but I get errors "tabBar undeclared", although I've imported the AppDelegate, where the tabBar was defined.
Thanks in advance!
Try setting
myViewController.hidesBottomBarWhenPushed = YES;
when you create your UIImageView. When you push it on to the view stack the UITabBar will hide automatically, and it will be restored automatically when you pop or dismiss the controller. No need for the application delegate.
If you want to show a full screen view, it is best to use a modal view controller. This way you do have to worry about hiding/showing navigation items. Take a look at:
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
to get started.