views:

1777

answers:

3

I'm having trouble merging the two concepts of using a SplitViewController in my main view and having the "RootView" controller that controls the left panes popup/sidebar table view.

I want to have the left "RootView" act as a navigation menu, but how do I do this when the RootView is tied through MainWindow.xib into the left pane of the SplitView?

Basically, I want the left navigation to work just like the built-in email applications folder drilldown navigation. Is there an example iPad project out there that uses both SplitView and a NavigationView for the left/Root pane?

+2  A: 

After you create a SplitView project, open up the RootViewController.m file and look at the -tableViewDidSelectRowAtIndexPath method. You'll see that the item that you clicked is then set as a property of the DetailViewController.

The design you're looking for would require that you push another view controller onto the navigation stack. So if you imagine the e-mail application, when a user picks a folder, the detailView is not updated, but the next level of the Inbox is pushed onto the stack. When a user selects a message from the inbox, the detail view is updated with the message contents, and the RootViewController just stays where it's at.

in the -tableViewDidSelectRowAtIndexPath method, declare your new view controller

NextViewController *nextView = [[NextViewController alloc] initWithStyle:UITableViewStylePlain];
//This assumes you have another table view controller called NextViewController
//We assign it to the instance variable "nextView"

[self.navigationController pushViewController:nextView animated:YES];
//tells the navigation controller to "slide" the "nextView" instance on top
//if animated:NO it wouldn't slide, it would just "update"

[nextView release];
//release the viewController, it's now retained automatically by the NavigationController

Does this make sense?

JustinXXVII
Thanks for the code and help! It makes sense!!!
MikeN
+1  A: 

I've been implementing this in my project. However, the RootViewController is designated as my SplitViewControllers delegate, so when I push another view onto its stack, I lose my UISVC's delegate and thus a button to display my MasterView when the iPad is placed in portrait mode. I've tinkered around and around, creating protocols to implement showing and dismissing a button when the iPad changes orientation, but it seems that every time I arrive at a possible solution, I'm setback with another problem. Any suggestions?

Romeo
A: 

Now this is fine, I figured this one out as well, but how do you update the DetailedViewController from the NextViewController ? Can anyone explain how to pass the value from the second UIViewController to the Detailed UIViewController ?

from the posted example above:

    NextViewController *nextView = [[NextViewController alloc] initWithStyle:UITableViewStylePlain];
Nikola Paunovski
Update second detailed view controller the same way you would update the first: Using the reference from the AppDelegate:<pre> NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil]; splitViewController.viewControllers = viewControllers; [viewControllers release];</pre>This is assuming you are using the SplitViewController sample project from Apple's code samples.
MikeN