Basically, I have two MasterViewControllers for a splitViewController,but I am only able to run the app with one of them at a time. Both MasterViewControllers are using the same DetailViewController. When the user push a tabbarbutton, the second masterViewController is pushed.
The splitViewController is straight forward declared like this in the AppDelegate
MasterViewControllerOne *mvc1 = [[MasterViewControllerOne alloc] initWithNibName:@"MasterViewControllerOne_iPad" bundle:nil];
UINavigationController *masterOneNavigationController = [[UINavigationController alloc] initWithRootViewController:mvc1];
DetailViewController *dvc = [[DetailViewController alloc] initWithNibName:@"DetailViewController_iPad" bundle:nil];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:dvc];
self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = @[masterOneNavigationController, detailNavigationController];
self.window.rootViewController = self.splitViewController;
During runtime, I want MasterViewControllerTwo to swap with MasterViewControllerOne
Action to push the new view controller:
MasterViewControllerTwo*mvc2=[[MasterViewControllerTwo alloc]initWithNibName:@"MasterViewControllerTwo_iPad" bundle:nil];
[self.navigationController pushViewController:mvc2 animated:YES];
This swaps in the mvc2 on top of mvc1. However, tapping the rows of the tableview in mvc2 does not activate the DetailViewController.
To activate the DetailView (identical for mvc1 and mvc2) I do following
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Item *theItem =[[self.items objectAtIndex:[indexPath section]]objectAtIndex:[indexPath row]];
[self.detailViewController setLabelsForItems:theItem];
}
Works very well as long the MasterViewController is defined in the appdelegate as member of the splitviewcontrollers array. So why doesn't the mvc2 activate the DetailViewController when it is on top of the stack?
tapping the rows of the tableview in mvc2 does not activate the DetailViewController
Well, that isn't going to happen magically all by itself. It's up to you to respond when a row of the second table view is selected. You haven't shown any code for doing that, so one assumes you have none.
In other words, a split view controller does nothing in and of itself except for containing the master and the detail. Communicating between the master and the detail is up to you. The template shows you the sort of thing you'll need to do.