iPhone : Problem regarding Hidden TabBar Controller? - iphone

I want to hide tabbarcontroller on one view.
But doing so it is displaying white space and not allowing to put any image or anything else on that place.
So what should I do ?

Put one imageView with your desired image on the view controller where you do not want to show tabBar and hide tabBarController before pushing that view on navigation stack using code like
[viewControllerInstanceWhichIsGoingToPushed hidesBottomBarWhenPushed];
The method is something like this. Then Tab Bar will hide and your imageView with image will be displayed in place of TabBar.

If you add a subview to a hidden view, the subview will also go hidden.
In your case, you can have another view controller with just the activity indicator and display the view controller while the loading operation is done. And, after the loading is over, remove that view controller and show the tab bar controller. An example,
// while loading the content
appDelegate.window.rootViewController = loadingViewController;
// once the loading is over
appDelegate.window.rootViewController = tabbarController;

I have encountered this problem before as well and was not able to get anything to get into the blank space using the normal hierarchy. I got around this problem by adding another level of navigation.
ex:
right now you have at UITabBarController which contains your UIViewControllers.
Instead:
Have another UIViewController as the root and then add the tabbarcontroller onto it either as a modalviewcontroller or as a pushed viewcontroller (if you make your root a navigationcontroller). Then, your rootviewcontroller can freely put views under or over the tabbarcontroller's view, independent of whether the bar is present or not.

Related

Display whole ViewController within another ViewController's view

Im writing an application which the main view controller is a UIViewController. It has some icons in a grid and I want to dismiss (sliding down) this grid when one of the icons is clicked. This I've done already. The problem is: when the grid is dismisseed I want another View to come from the top of the screen. This view is in this same root view controller. But I want to display the content of other view controllers in this view. For example: I want this view to show a UINavigationController with a UITableView inside it, so the user can navigate through TableViews.
I'm doing this:
HorariosViewController *horarios = [[HorariosViewController alloc] init];
[vuashView addSubview:horarios.view];
HorariosViewController is a UINavigationViewController. It shows me only a blue NavigationBar and changes like self.navigationItem.title = #"Title" won't work.
Thanks!
You can show another view controller's views as subviews but their outlets and actions remain linked to their original view controller unless you write code to make new connections, so self.whatever shouldn't be expected to affect the other view controller's properties.
(Also, if HorariosViewController is a UINavigationController, it shouldn't be created as a UIViewController.)
One approach is to have the navigation controller already there, with the icon grid presented modally on top of it. (you can set the view up this way without animations, so the user doesn't see the navigation controller underneath).
Then, when it's time for the grid to go away, it can call dismissModalViewController on itself with animation.

UITabbar loads 2 views on app start instead of just the first one

I have a uitabbar with 4 buttons. The start up screen loads as it should on the applications start. 2 of the buttons views don't load on start (good). 1 is a web view the other is a navigation controller with a table view. The last view does load on application start. It is another navigation controller with a table view.
I know which ones are loading and which are not because i added nslogs to the didload function on all top level controllers.
So the overall issue is that when i start my app, then rotate it, then go into the tabbar item that has already been loaded the header in the tableview which is a webview, never got the memo that it should have rotated, and therefore resized. Once your in the view if you rotate back and forth then it works as it should. Its just the initial time.
Update 1:
The question is how do I stop the 2nd controller that is on another button of the tab bar from loading on app start.
Update 2:
I do all my init stuff in didload but I tried adding the following code, but it never shows up in the log. I am not using IB, this is all done programmatically:
- (void)loadView
{
NSLog(#"Loading feedback");
}
Update 3:
I figured out whats causing this. I do have a xib that houses my tabbarcontroller. In that tabbarcontroller i have a navigation controller, then i have a view controller (I set the class to my feedback class), then i had the navigation item and a table view. When i add the tableview it triggers the controller to load. Simply removing that will stop it form loading early. Then to fix it, i created a xib for the feedback. So I dont like having nibs that server a single purpose, in this case its to get a table view in there and have it be a grouped style. I may try to just manually add the tableview instead of having a tableview controller.
Its much easier to do in code. The tab bar controller accepts the view controllers in the array and the default tab bar controller is the one which is at the first index of the tab bar controller.
UITabBarController *tabBarController = [UITabBarController alloc] init];
tabBarController.viewControllers=[NSArray arrayWithObjects:firstViewConoller,secondViewController,nil];
[self.view addSubview : tabBarController.view];
Place all the view related task in viewDidLoad method sometimes loadView gies problem this may be because of your viewController trying to load a new view which calls itself again and again so better to add them to viewDidLoad.
The view controller for the tab that loads prematurely probably accesses the self.view property before it is needed needed.
If finding he access point is hard add a breakpoint to loadView, make a dummy overload only calling [super loadView] if needed (The view is loaded from a NIB). The breakpoints stack trace will show you where you force the load to occur.

Non-Modal view without NavigationController

I have an app built from the UITabBarController starter project. The first tab is part of the main.xib that contains the tab bar. I would like to slide a view up from the bottom on top of that tab's view that only covers part of the screen. My understanding is that you can only cover part of the screen if you make the top view non-modal, but I don't see a way to do that without a NavigationController.
How can I do this?
you can add a UIView as a subview to the current view, and then animate its appearance into the screen using animation blocks, or Quartz or however you would like.
presentModalViewController: is actually a method that belongs to UIViewController, the superclass of UINavigationController, so you can use it from any view controller, not just a navigation controller.
Have you tried using a UIActionSheet? That's an easy way to get a view with a few buttons for user input to slide up and only cover the bottom portion of the current view.

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.

Sliding Up/Down a UINavigationController

I have an app that uses a UINavigationController as its main way of showing data.I want a Settings screen to pop up, but I also want to be able to push new views for Settings. From what I've found, I can't use a UIViewController do to this. How can I present a view by sliding it, and also have content pushed onto it?
You can display the view for your view controller subclass either by presenting it modally (slides from the bottom and takes over the whole screen) or pushing it onto the navigation stack with animation (slides from the right and keeps the navigation bar).
In either case, you control the content of the view using your view controller subclass. Typically you update labels and controls in the viewWillAppear method.