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.
Related
Is there a way to set the view controller on the tab bar controller programmatically? Lets say I want it to show the second's tab view controller programmatically, is there a way to do that?
This is useful if I logout from my app, which is done from my third tab, when the user logins it should start from the 1st tab again. When I logout I am just showing a present modal view controller on top of what the previous view is, so I somehow needs to reset it again to the first tab bar without re-initializing it all over again.
The issue is now how do I do this?
From Apple's documentation it looks to me like you could just call the following two functions:
[myTabBarController setSelectedIndex:0];
[myTabBarController setSelectedViewController:[myTabBarController.viewControllers objectAtIndex:0]];
Hi ye you can do this
You might have tabbarcontroller object in appDelegate.
So on logout button
make object on your appDelegateClass and do this:-
appDelegate.tabBarController.selectedIndex=0;
Have a look at the reference on UITabBarController. Work with selectedIndex and selectedViewController.
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 want to present a Modal view in the middle of the screen in on an iPad. This view will have a search bar and a table view. It will present search results. This is up and running.
Now i need to add a navigation controller so that upon touching a row in the above table view, a detail view will be pushed in from the right to allow the user to determine if this is the item he wanted.
I tried adding a navigation controller to my modal view but it doesn't display and i couldn't find a tutorial for this.
Can someone please give me a hint?
EDIT: I'm starting to think that i first need to push a modal navigation controller and then add the tableview to this, is this the correct approach? Can someone please give some details on this if that's the case?
Yes this is possible. You have to present the NavigationController modal. Your ViewController will be the rootViewController of the UINavigationController.
I posted some code in Adding UINavigationController to existing UIViewController
I'm trying to write an application that uses a navigation bar and tab bar in what (I'm gathering) is an unusual manner.
Basically, I've got several "pages" ("home", "settings", etc) that each have their own tab. I'd also like to have it so that the "home" page is the root view of the navigation bar, and the other pages are the second-level views of the navigation bar. That is, I should be able to navigate to any page by clicking the appropriate tab bar item, and should be able to navigate to the home page from any other page by clicking the navigation bar's back button.
Currently, I have a UINavigationBar (through a UINavigationController) and a UITabBar (through a UITabController) as children of a UIView. The various pages' view controllers are set as the tab controller's viewControllers property, and the home page's controller is also set as the navigation controller's root view. Each page view's tag is set to its index in the tab control. I have the following logic in the tab controller's didSelectViewController delegate method:
- (void) tabBarController:(UITabBarController*) tabBarController
didSelectViewController:(UIViewController*) viewController
{
if ([navController.viewControllers count] > 1)
[navController popViewControllerAnimated:NO];
[navController pushViewController:viewController animated:YES];
}
Also, in the navigation controller's didShowViewController delegate method, I have the following code:
- (void) navigationController:(UINavigationController *) navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
tabController.selectedIndex = viewController.view.tag;
}
The problem that's occurring is that when I run this, the navigation bar, tab bar and home page all display ok, but the tab bar will not respond to input - I cannot select a different tab.
I gather it's more usual to have the tab bar as the child of the navigation control, or vice versa. This doesn't seem to fit my approach, because I don't want to have to individually create the subordinate control each time a change occurs in the parent control - eg: recreate tab bar each time the navigation bar changes.
Does anyone have suggestions as to what's wrong and how to fix it? I'm probably missing something obvious, but whatever it is I can't seem to find it. Thanks!
EDIT: I'm guessing it has something to do with both controller's trying to have ownership of the page controller, but I can't for the life of me figure out a way around it.
Yikes. You're way out on a limb here. I've learned the hard way that UINavigationController and UITabBarController aren't very accommodating when you try to use them in nonstandard ways. UINavigationBar and UITabBar weren't designed to coexist as siblings in the view hierarchy. They really want to be distant cousins. Maybe the approach you're pursuing can be made to work somehow, but I personally wouldn't even attempt it.
With that said, I'll suggest one thing you can check, and then I'll tell you how I'd approach the problem.
Have you implemented, and are you returning YES from tabBarController:shouldSelectViewController: in your UITabBarControllerDelegate? If not, that would prevent your tabs from switching.
Assuming that won't solve all your problems, here's what I would do to get the behavior you're seeking:
Create a UITabBarController and set its view as the root view of your window.
Have a separate UINavigationController under each tab, each with its own navigation bar. (This is the standard way to use UINavigationController and UITabBarController together.)
Set a UITableViewController that displays an identical copy of your main menu table as the root view controller for each navigation controller.
When a row is selected on your "Home" view controller, switch to the associated content tab.
Set a delegate on your UITabBarController. In its tabBarController:didSelectViewController method, call pushViewController:animated:. This is similar to what you're currently doing, except you'll be calling it on (UINavigationController *)tabBarController.selectedViewController.
In the viewDidAppear:animated: of the root view controllers of your content tabs, switch to the "Home" tab. This way, when the user hits the back button to go back to "Home", it will switch to the right tab. (You may also need conditional code to prevent this from happening when the user first selects a content tab. I'm not sure.)
I'll be curious to know if Apple accepts this nonstandard behavior. Come back and let us know. Also, let us know if you get your approach working somehow.
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.