I am having some issues on UI design.
Alternative 1:
UINavigationController
TabBarController
MapViewController
UINavigationContoller
UITableViewController
DetailViewController
Alternative 2:
UINavigationController
TabBarController
MapViewController
UITableViewController
DetailViewController
In alternative 1 in the navigationitem of DetailViewController the backButton and the title are not being shown but I have the lower tabbar.
In alternative 2 in the navigationitem of DetailViewController the backButton and the title are visible but I am missing the lower tabbar.
Is there any way to have both features of alternative 1 & 2?
I need the the top most Navigation Controller because in the TabBarViewController I have a LeftBarButtonItem showing a side menu (SWRevealViewController).
EDIT
Code in TableViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
poiDetail = [poiManager.listOfPois objectAtIndex:indexPath.row]; // does not work with regions-sections
[self performSegueWithIdentifier:#"poiDetail" sender:self];
}
where "poiDetail" segue is a push e.g. 'Show' segue.
Yes I implemented same scenario and facing the same issue, Fortunately I am able to solve this in my application,
I am suggesting Alternative 1
You can set Initial UINavigationController in AppDelegate and maintain application flow with same navigation controller till nested UINavigationController. And set TabBar controller as a RootViewController
In RootViewController of nested NavigationController please hide AppDelegate navigationController's NavigationBar. So you are able to resolved issue of Alternative 1 that you are facing.
I referred this library: https://github.com/juliorimo/CustomTabBar-iOS
(Note: This library is just one UINavigationController and TabbarController further Nested UINavigationController flow you have to maintain)
Hey I propose Alternative 3:
UINavigationController
Tab Bar Controller
Nav Controller
Map View Controller
Nav Controller
Table View Controller
Detail View Controller
You essentially want the two View Controller managed by the Tab Bar Controller to be wrapped in Nav Controllers
Related
I have the following in Interface Builder:
The top left is my main view controller where I have 2 buttons that have segue to two UIViewControllers. These two UIViewControllers are linked with the Tab Bar Controller. However, how could I make those 2 buttons to link to specifically to one/other views? Right now it's connected specifically, but it (or something else) causes the bar tab not show up.
Is it the problem that I don't have the Tab Bar Controller connected to the main view?
Yes, you're right that the problem occurs because the tab bar controller needs to be the destination of the segues. Fix it like this:
In IB, erase the segues from the two buttons and create two new ones, one from each button to the tab bar controller. Give each one an identifier, like buttonA from one button and buttonB from the other.
In the view controller, implement prepareForSegue for each segue understanding that the destination is a tab bar controller and that each segue requires a different tab selection...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"buttonA"]) {
UITabBarController *tabBarController = (UITabBarController *)segue.destinationViewController;
tabBarController.selectedIndex = 0;
}
if ([segue.identifier isEqualToString:#"buttonB"]) {
UITabBarController *tabBarController = (UITabBarController *)segue.destinationViewController;
tabBarController.selectedIndex = 1;
}
}
That's not quite how the tabBarController works.
I can see your initial view controller is the one on the top left, and it pushes either of the other two on the right on to the navigation stack if you push a button. But in your current setup, at no point does the tab controller itself get pushed on to the stack.
Instead, you would want to have your initial view controller push the tab bar controller on to the stack, through a button or otherwise, and the tab bar controller will display your other two view controllers as its setup to do.
I have the next structure:
* TabBarController
- ViewController with TableView
- ViewController
When I select any row on the TableView, the segue forwards me to the ViewController. On the ViewController with the TableView, I see the BottomBar, but after the segue it disappears.
How can I keep it on my ViewController? I've even putted the last ViewController in NavigationController, but it did not help me, too.
How can I fix it?
Your hierarchy should look like this:
* TabBarController
- NavigationController
- ViewController with TableView
- ViewController
Using a Show segue with an UINavigationController pushes the destination view controller onto the navigation stack. However, most other view controllers present the view modally (i.e. by sliding over the source view controller) with Show, which is why your tabbar disappears.
uncheck hide bottom bar when pushed from your view controller in story board
Currently I'm using storyboards to segue between controllers. I have a UITabBarController with a UINavigationController for each tab.
All my root UIViewControllers in their UINavigationControllers return the following when I log out the tab bar controller:
Tab Bar Controller: <UITabBarController: 0x7f7ff958d3b0>
However when I programmatically push in a new VC in the following manner:
//Show New VC
UISecondViewController *secondController = [[UISecondViewController alloc] init];
[self.navigationController pushViewController:secondController animated:YES];
and log out the tab bar controller in secondController, I see:
Tab Bar Controller: null
What's going on here?
Update:
At first I thought it could be an issue with using multiple storyboards, but when I push secondController in store.storyboard using a storyboard segue it works perfectly. The problem is this subclass controller I'm trying to push was built to only work programmatically (third party).
Main.storyboard
Store.storyboard
I am working on a new project of mine and am looking for what the best solution to keep the UITabBarController displaying even when using a segue to push to a UIViewController.
Currently I have an Initiation of our UITabBarController on app launch, which contains multiple viewcontroller relationships. Particularly the initial view controller option is a custom UIViewController which implements a UITableView. Once a cell is selected I call a show(push) segue to another UIViewController. This is where I lose my TabBar which is as expected. Now I have tried different approaches such as setting the hidden value of our tabbar to YES, but does not seem to help.
Code
When Cell Selected:
[self performSegueWithIdentifier: #"tableCellOptions" sender: self];
When preparing for segue:
if([segue.identifier isEqualToString:#"tableCellOptions"]) {
additionUITableView *move = (additionUITableView *) segue.destinationViewController;
move.thisOption = [menuOptions objectAtIndex:cellPushed];
}
What would your approach be to this and why?
If you have Tab bar controller as the initial View Controller, the tab bar will show by default on each view controller.
If you are using storyboard or xib file, then select the tab bar item in view controller and check its properties, and make sure "hide tab bar on push" is unchecked.
Programmatically you can do this,
self.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:viewControllerToPush animated:YES];
Place it in viewDidLoad or viewDidAppear.
I hope this solves your problem.
I create a UINavigationController in storyborad,and UINavigationController control a TabbarController
If tabbarcontroller have three viewcontroller,each viewcontroller has a tableview use autolayout,when app launching,The ViewController from TabbarController which first show,index 0 as usual,the tableview view is complete show on this viewcontroller,but switch another index viewcontroller,the tableview is uncomplete show,it is hide by navigationbar,the autolayout was not take effect
thanks!
I deal with it by my self,If UITabbarController contains three UIViewControllers, each UIViewController have a UINavigationController