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
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.
after reading a lot of tutorials and threads here on stackoverflow there is one basic question left in my head.
The structure of my App should be the following:
MainMenu - fullscreen without a navigation bar but 2 buttons (button1 and button2)
Page1 - should appear by pressing button1 and should have a navigation bar at the top with a "back"-button to get back to the MainMenu.
Page2 - should appear by pressing button2 without a navigation bar at the top. Page2 should be a UISplitView. There must be a back button somewhere.
(I think this is where the problem starts, a UISplitView can't be presented modally, can it?)
You should be able to add subpages to Page1.
So how can I do that? I don't need executable code but just a hint on how the structure of my app should be. For example where to add the navigation controller, how the MainMenu looks like.
Thanks in advance!
Are you trying to create an Application for iPad?
Your Application's UI sems inconsistent being First View the only view without navigation Bar.
You will be using standard navigation to navigate to page1 from home page. So you will be adding a navigation Controller with Home View Controller as a Root View COntroller with hidden navigation bar.
eg.
-(void)applicationDidFinishLaunching:...
{
HomeViewController * hvc = [[HomeViewController alloc]init];
UInavigationController * nvc = [[UINavigationController alloc]initWithRootViewController:hvc];
nvc.navigationBar.hidden = YES;
[window addSubView:nvc.view];
}
Then on tap of first Button you will be pushing the Page1 View Controller
-(IBActtion)button1Pressed:(id)sender
{
Page1ViewCOntroller * p1vc = [[Page1ViewCOntroller alloc]init];
[self.navigationController pushViewCOntroller:p1vc animated:YES];
}
In viewWillAppear: method of Page1ViewController unhide the NavigationBar and hide it in the viewWillDisappear: method
Your Page 2 needs to be splitViewController.
Now about Split View, Apple says
The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface.
But as there is no "must" written in the above statement, and since its finally a View Controller in itselt, you should be able to add it on the window or another view.
Try to create a VIewController, with split VIew added on it, and like page1, push the View on the navigation Controller.
I have a tab bar controller and a navigation controller. Each tab bar item has its own navigation controller and a few views within those.
I want to programitically switch to another view in a another navigation controller and have the correct corresponding tab bar item selected.
Is this possible, if so can you show me how ?
Heres some typical lines I'm using at the moment within the same navigation controllers.
[delegate.settingsNavController pushViewController:nextController animated:YES];
[delegate.reportNavController pushViewController:nextController animated:YES];
When ever I try this, nothing happens, I stay in the current view, however if I were to tap another navigation button and the view I'd tried (with code) wasn't normally the first view, that view would show first.
So it is changing the view within the navigation controller, but its not showing it.
You also have to switch to the new tab:
self.navigationController.tabBarController.selectedIndex = settingsTabIndex;
[delegate.settingsNavController pushViewController:nextController animated:YES];
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;
}
I have an application with a Tab Bar Controller that has three tabs.
In tab 1 there is a view (view1) with a button that when clicked transitions the user to a new view (view2) still within tab 1. However when this new view (view2) is loaded it covers my tab bar controller.
What is the best approach for me to take to still display tab bar controller as well as keep tab 1 highlighted?
How are you performing your "transition" to view2 from view1?
One solution is to use a UINavigationController as the root view controller for tab1, so view1 can display view2 by pushing it on the navigation controller. Alternatively, have view1 display view2 modally.
Either way should not cover your tab bar, and tab1 will still be selected (highlighted).
I think you are pushing the view as modal view if this is the case then the view will definitely cover your tab bar the other way to do this is push the view controller and this will not hide your tab bar.
Try to do it like:
[[self navigationController] pushViewController:viewContObject animated:YES];
Hope this helps,
Thanks,
Madhup