Reputation: 3771
I have moved from UITabBar to split view on my iPad application.
The view controllers are sent by the master to the detail which puts them into a UINavigationController.
// Detail manager called when a cell is selected on the master
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:_detailViewController];
UIViewController *mainNavigationViewController = [self.splitViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:mainNavigationViewController, detailNavigationController, nil];
self.splitViewController.viewControllers = viewControllers;
Now every time a cell on the master is selected, the navigation controller on the detail view starts from the root.
Instead I would like to have the same behavior of the tab bar controller: when you move from one tab to another, the navigation stack for each tab is maintained. And when you select two times the same tab, the navigation stack pops to the root view controller.
How to implement this in a proper way with a split view based application?
Upvotes: 0
Views: 189
Reputation: 3771
Starting from the suggestions of Levi I implemented a working solution. To summarize:
UISplitViewController
UINavigationController
you needUISplitViewController
subclass initialize all the navigation controllers with their respective root UIViewControllers
UISplitviewcontroller
subclass) is presented on the detail view. I managed this with an NSinteger
property on the detail manager (set on master cell selection) to tell it which navigation controller to present on the detail view.UITabBar
behavior.Hope this will help someone.
Upvotes: 0
Reputation: 7343
You should make a navigation controller for each cell in the master table. When tapping a cell, you switch it accordingly. If the selected cell is tapped, you call popToRootViewController:animated:
on the visible navigation controller. Of course, you have to subclass UISplitViewController
to keep a reference to your navigation controllers. You would also have to create a MaterTableDelegate
to tell you split VC, he should change the navcon in the detail side.
Upvotes: 1