How to show and hide tab bar at required places? - iphone

Hi i am making an application where ther are four screens(view controllers) from 1 to 4. I want to show screen 1 without tab bar .This screen will have three buttons through which user can navigate to other screens. Now when user taps screen 2 button then user should navigate to screen 2 with tab bar on bottom.Now this tab bar will have four tabs from screen 1 to 4 to navigate .Similarly when now user tap on tab 1 then the scrren 1 should arrive which is without tab bar and so on.
My problem is i am not able to load or unload tab bar at required places.I have tried following:
I opened screen 1 on statrt up and on screen 1's view did load added the tab bar but it didnt work
I added tab bar on main window but then tab bar starts to show even on screen 1.
PLease tell me the correct way to do this (In other words a tab bar with four tabs in which the first screen should not show tab bar)
Thanks in advance

use this single line
self.hidesBottomBarWhenPushed=YES;
for hide tab bar. use this before push the page where you want tab Bar hidden and also write this line
self.hidesBottomBarWhenPushed=No;
at same page from where you are going to push in viewWillDisappear.

self.window.rootViewController = self.navigationController;
First add your rootviewcontroller in the window.
and add three buttons in it.
on clicking event of button add tabbarcontroller to mainwindow
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = btntag; //ur button tag;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];

Related

how to change view in ios tabbed application without changing tab and maintaining tab bar visible

i have an iphone project that is a tabbed application.
In the first tab I have a login form and I want that the user data returned by the login funcion to be shown in another view that takes the place of the view that contains the login form, without changing tab, and without taking all window's space because I don't want the tab bar to be hidden.
How can I do this (without storyboard)?
CMAnagrViewController *reg = [[CMAnagrViewController alloc] initWithNibName:#"CMAnagrViewController" bundle:nil];
UIWindow *topWindow = [[[UIApplication sharedApplication].windows sortedArrayUsingComparator:^NSComparisonResult(UIWindow *win1, UIWindow *win2) {
return win1.windowLevel - win2.windowLevel;
}] lastObject];
//topWindow.rootViewController = reg;
[topWindow addSubview:reg.view];
if I do like this the view is too high and part of the navigation bar goes under the status bar and part of the tab bar is out of the screen, but if i uncomment the
//topWindow.rootViewController = reg;
line then the new window goes full screen and i see all the navigation bar under the status bar but there's no tab bar..
Thank you all!

how to add a uitab bar controller with non of the tab get selected?

I have added an UITabBarController. My requirement is to display a view with tab bar controller. but that view is not part of the tab bar items. For example my tab bar contains 3 tabs
contacts
camera
history
Generally if we add tabbar controller contacts will be get selected and that view will be displayed automatically. but i don't want in that way...
i used [tabBarcontroller setSelectedViewController=nil];
i am able to get a tab bat with non of the tab get selected. but when i am trying to select a tab item it's not working.. I think i set the selectedViewController to nil. is there any other way to achieve my requirements...?
please explain your answer clearly.. i am new to iphone app development..
Present a view controller which is not a part of your tab bar controller and put a tab bar image/buttons at the bottom of it which resembles your tab bar. When you receive a button pressed message from within that view controller, show that tab on screen.

How can I switch from one UITabbarview controller to another UITabbarViewController in iPhone?

I have an UITabbarViewController with 3 tabbar items with a navigationbar. When I will press my first item of tabbar item there will be a button at the view.
Now my question is when I will press the button, then it will go to the another tabbarview controller which have also 3 tabbar items. How can I do that?
UITabbarViewController[with navigation bar]--->tabaritem [1] + tabaritem [2] + tabaritem [3]
tabaritem [1] viewcontroller is taking a button when I will press button the another UITabbarcontroller will be shown at the screen.
UITabbarcontroller[2] [with navigation bar]--->tabaritem [1] + tabaritem [2] + tabaritem [3]
I am new to iPhone application development.
One more thing is that I can't use table view for two tabbarcontroller because my first tabbar item of first tabbar is taking a login page so when user will able to log in then he will see second tabbarviewcontroller.
Instead of swapping out the whole controller, why not just remove and add tab bar items for each of your modes? When your in your first mode, show tab bar items 1,2 and 3. If someone hits one, then remove all those items, and add items 4,5 and 6. Use the tag on the items to keep track of them.
The only way to do this, according to apples viewpoints, is to show one of the tab bars in a modal.
It seems like you're using the first Tabbarcontroller as a Login controller. In that case, you would have this as a Modalview over you're other (normal) Viewcontroller. On Application Start, you load the main tab controller.
You then check if the user is logged in and show the Model Logging Controller (which is a Tabbar controller again) if he isn't.
Once the user has successfully logged in, you just dismiss the Modal, and voila, you got the "main" tab controller visible.
[edit:] here's a short example in (Pseuod) code:
MainViewController.m:
-(void) viewWillAppear:(BOOL)anmiated
{
UIApplicationDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
if (!appDelegate.isLoggedIn) {
appDelegate.loginController = [[UIViewController alloc ] initFromNib:#"login"];
[self presentModalViewController:appDelegate.loginController animated:NO];
}
}
in the LoginController
- (iBAction) loginClicked
{
[appDelegate.mainViewController dismissModalViewControllerAnimated:YES];
}
This obviously assumes that you have references to your view controllers in the appdelegate.

Navigation Controller with Tab Bar only on first view

I am seeking advice on how to start my project.
I need to use a combination of the navigation controller and tabbar controller but on the second screen, I need the tabbar controller not to be there. Here is a brief description of the two main screens
Screen 1 will have a tabbar controller with two tabs. The first tab is a tableview and when you tap on a table cell, it drills down to Screen 2. The second tab is just a filter view that updates the table in the first tab of Screen 1.
Screen two is just a details screen from the cells of Screen 1. The catch is that I don't want the TabBar on Screen 2.
I am struggling with how to get started.
Do I start with a Navigation-based application since I need to be able to drill down? How do I just add a tab bar to the main screen of the navigation based app?
I can't start with a Tab Bar application because if I load a navigation controller inside one of the views of the tab controller, then when I drill down inside the nav controller, the tab bar still stays on the next screen when I need it to go away.
Any help would be appreciated.
Hide the tab bar once the 2nd view gets pushed. You can hide it in the viewDidAppear method and animate it so that it looks fluid.
The navigation controller has a property that will do the work for you (put this just before you call the nav controller to push the new view):
navigationControllerNameHere.hidesBottomBarWhenPushed = YES;
or
- (void)viewWillAppear: (BOOL)animated {
self.hidesBottomBarWhenPushed = YES;
}

Tab bar navigation

I have made an application in which I have four tab bars. I have used the below code to go to the second view in a button's click method. It goes to the second view but the second view is not showing with tab bars. How can I fix this?
- (IBAction)Existinguser:(id)sender
{
ExistingUserViewController *existingUserViewController =
[[ExistingUserViewController alloc]
initWithNibName:#"ExistingUserViewController" bundle:nil];
[self presentModalViewController:existingUserViewController animated:YES];
[existingUserViewController release];
}
Presenting a view controller modally will show that view controller above all ther other UI elements (this includes the navigation bar and tab bar, but not the status bar).
If you want to show your "second view" as the view on the second tab, then you need to set the view controller you want to use as the second tab's view controller. That way when you press the second tab, the second view controller will be shown, and the second tab will be selected and visible.
I might be mistaken, but do you have a single tab bar with four tabs and you are looking for a way to change to the second tab? You can do this with the following code:
self.tabBarController.selectedIndex = 1;
btw the code you attached to your question is displaying a new model view controller above the current view controller. This is the reason no tabbar is shown.
If you are trying to create a navigation based app using tabbar, in IB, change the tab's viewcontroller to UINavigationController. You can then use the UINavController methods to navigate between views. In case you don't want to show the navbar, just set that property in IB.
Here's a good example of how you can use tab bar with navbar