Multi-level navigation controller on left-hand side of UISplitView with a small twist.
- by user141146
Hi. I'm trying make something similar to (but not exactly like) the email app found on the iPad.
Specifically, I'd like to create a tab-based app, but each tab would present the user with a different UISplitView.
Each UISplitView contains a Master and a Detail view (obviously).
In each UISplitView I would like the Master to be a multi-level navigational controller where new UIViewControllers are pushed onto (or popped off of) the stack. This type of navigation within the UISplitView is where the application is similar to the native email app.
To the best of my knowledge, the only place that has described a decent "splitviewcontroller inside of a uitabbarcontroller" is here: http://stackoverflow.com/questions/2475139/uisplitviewcontroller-in-a-tabbar-uitabbarcontroller and I've tried to follow the accepted answer.
The accepted solution seems to work for me (i.e., I get a tab-bar controller that allows me to switch between different UISplitViews).
The problem is that I don't know how to make the left-hand side of the UISplitView to be a multi-level navigation controller.
Here is the code I used within my app delegate to create the initial "split view 'inside' of a tab bar controller" (it's pretty much as suggested in the aforementioned link).
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSMutableArray *tabArray = [NSMutableArray array];
NSMutableArray *array = [NSMutableArray array];
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
MainViewController *viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
[array addObject:viewCont];
[viewCont release];
viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[array addObject:viewCont];
[viewCont release];
[splitViewController setViewControllers:array];
[tabArray addObject:splitViewController];
[splitViewController release];
array = [NSMutableArray array];
splitViewController = [[UISplitViewController alloc] init];
viewCont = [[Master2 alloc] initWithNibName:@"Master2" bundle:nil];
[array addObject:viewCont];
[viewCont release];
viewCont = [[Slave2 alloc] initWithNibName:@"Slave2" bundle:nil];
[array addObject:viewCont];
[viewCont release];
[splitViewController setViewControllers:array];
[tabArray addObject:splitViewController];
[splitViewController release];
// Add the tab bar controller's current view as a subview of the window
[tabBarController setViewControllers:tabArray];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
return YES;
}
the class MainViewController is a UIViewController that contains the following method:
- (IBAction)push_me:(id)sender {
M2 *m2 = [[[M2 alloc] initWithNibName:@"M2" bundle:nil] autorelease];
[self.navigationController pushViewController:m2 animated:YES];
}
this method is attached (via interface builder) to a UIButton found within MainViewController.xib
Obviously, the method above (push_me) is supposed to create a second UIViewController (called m2) and push m2 into view on the left-side of the split-view when the UIButton is pressed.
And yet it does nothing when the button is pressed (even though I can tell that the method is called).
Thoughts on where I'm going wrong?
TIA!