I have following set up in the interface builder:
Files' Owner
First Responder
App Delegate
Window
-> Tab Bar Controller
Tab Bar
->Selected Navigation Controller (X)
Navigation Bar
->X View Controller (X Class)
Navigation Item
Tab Bar Item (X)
->Navigation Controller (Y)
Navigation Bar
->Y View Controller (Y Class)
Navigation Item
Tab Bar Item (Y)
X and Y tab bars have their own nib's.
In my app delegate, I add tab view controller to the main window view:
[window addSubview:tabController.view];
[window makeKeyAndVisible];
And all this works great. However, I now need to insert a view with two buttons. One button would take me to above explained tab controller view. The second button would take me to another subview (not yet implemented) which will only have an other action button in its view.
I should be able to navigate back to the main window (two buttons) from any of the subviews.
Is this possible? How to do it?
I don't know if this helps, but probably what you need here is a UINavigationController. With such a controller, put as the main view controller of the app, you can create the two buttons, and when the user touches one of them, you change the navigation controller display using its pushViewController:animated: method.
In this way you obtain the classic backwards arrow button item in the toolbar of the new view that will permit you to go back to the home page.
Related
So I have this application where I have a view controller (which I want to appear first when the app starts) and a tab bar controller. I also have other navigation bar controllers that are in the tab bar controller. I want to place my view controller on top of the tab bar controller. Making the tab bar controller the parent of the view controller would be better though.
But take note, I do not want a tab bar item to represent the view controller and I want the tab bar to appear along with the view controller. I do not and would not want to use storyboards as much as possible. How can i achieve this?
I guess the simplest solution would be to use a screenshot of your tabBar and put it in your HomeViewController as a button. In this case you could use your HomeViewController as rootViewController and in the button action you set the TabBarController as the rootViewController.
Root = Home + Button
-->
Root = TabBar
Perhaps you need four buttons, if you want the correct tab to be selected.
I have an issue with a tab bar app. I am making a tab bar app with three bars on the bottom. On my my first bar it is a tableviewcontroller. When i ckick on the table view controller it takes me to a different view (which doesn't have the tab bar). When I clicked back to the home screen (which has the tab) the tab bar is gone.If you need a picture i will post it!
You may have set your UITableViewController segue to a modal style. If this is the case, you should change it to a push style.
In order for a push to work, your view controller needs to be in a UINavigationController. In your story board, select your root view controller and embed it into a Navigation Controller like this...
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;
}
Let's have an example.
In application I have a tab bar controller.
Tab bar has two items dynamically - two view controllers.
User can select any of tab.
Suppose user selects first tab.
First view controller is already loaded.
Now he clicks on a button of First view controller.
From First View controller -> Second View controller is pushed.
Now when user taps on tab bar first item
second view is popped out.
This is done through by default by tab bar controller.
Now, If I want to check following condition
if(tab bar first item-view controller has first view controller view)
then perform this
if(tab bar first item-view controller has second view controller view)
then perform this
How to implement this logic?
If you are using a UITabBarController, you can use its selectedViewController property to know what kind of view controller is on the screen, so if you have two subclasses of view controller FirstViewController and SecondViewController you can say
if([[tabBarController.selectedVIewController isKindOfClass:[FirstViewController class]])
//... do something
else ...
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