Hiding Tabbar still occupy Space? - iphone

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.

Related

iOS tabBarController is not displayed

I have a main tabBarController with some tabs as main controller and each tab contains some objects. Once a view is called, for example, pressing one cell of tableview, tabBar dissapears using,
AppsViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:AppsViewController animated:YES];
New view contains a new tabBarController but it is not displayed! How to solve it? If not possible, another option would be insert a tabBar (is displayed properly!) instead of tabBarController and then handle its control programmaticaly. How? any help would be appreciated. Thank you.
Honestly speaking i dont use Tab Bars . it gets very complicated in certain conditions to customize it. What i do is that i place some Custom Buttons in place of tabs. and let the designer do the rest. the images of the buttons look exactly like a tab bar in ur app and u can easily customize it the way u want it
i could have shown u the snap shot of my recent app which looks like a tab bar but consists of custom buttons
let me know what u think about it
Cheers
W
If you are talking about UITabarController you can't select a controller in a tab that is also a tabbarcontroller. The only way to do it is presenting it modally. In the hig and view controller programmming guide is clearly explained why. The reason is about view controllers hierarchies.

Why do positions of my UI elements change on popViewController?

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.

Getting empty view and blank navigation bar when I use popViewControllerAnimated

I'm writing an iPhone app that is based on a UINavigationController. I'm pulling data from a server that sometime returns bogus links. I open each link by pushing a webview viewcontroller. I want to be able to include some error handling. I know if the link is no good. So I want to be able to pop the webview view controller as soon as I know that my webview has encountered an error.
Currently, I've tried using the following code:
[self.navigationController popViewControllerAnimated:YES];
I then get a Navigation bar with nothing displayed in it, but if I click where the "back" button should be it operates appropriately. The title pops up when I click where the "back" button should be. The view where the viewcontrollers usually display there content is blank white too even though I'm popping back to a UITableViewController.
I've tried this as a workaround:
UINavigationController *nav = self.navigationController;
[self.navigationController popViewControllerAnimated:YES];
[nav.visibleViewController.view setNeedsDisplay];
I've checked the viewControllers array in the UINavigationController and it has the right viewcontrollers in it (ie it has removed the viewcontroller for the webview).
I also tried putting code in the viewWillAppear of the viewcontroller I'm popping back to, but the method is never getting called.
I'm looking for a way to force the UINavigationController to reload the same way that you can call reloadData on a UITableView.
Any help would be greatly appreciated.
I saw something like this on my app where I was using a navigation bar I added in Interface Builder on the root view of a navigation controller and then programmatically creating the nav bar and its subviews for the second view. When I would pop the second view to return to the first view I would hide the self.navigationcontroller bar which would show the white space underneath until the IB nav bar of the previous view appeared. To fix this I decided to stick with programmatically creating all my navbars which fixed the issue for me.
TL;DR - if you are using both IB and programmatically made navbars this can happen when popping views, stick with one or the other for all the navbars yo

Switching Views within UITabBar View

I have created an UITabView application. Each view selected from the bar is a seperate controller with own nib file. I switch between them succesfully.
In the first view I have two buttons (check out the screenshot). When clicking them I want to switch to another views which are the parts of the current view controller. I use:
[self presentModalViewController:anotherViewController animated:NO];
That switches the view, but hides the UITabBar. How to keep the bar on the screen after the switch?
P.S. Sorry for the blurred image. I am not allowed to share to much info.
Well I think you are misusing the modal view controller. For a problem like this I'll say you should put them in a view controller stack using UINavigationController. Instead of making each tab a UIViewController make it a UINavigationController, then you can push and pop view controllers on it, which still show the tab bar.
See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
use: tabBarController.selectedViewController = newViewController
edit: UINavigationController is not needed here.

How to hide an iPhone Tab Bar?

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.