I've made a diary application for iPhone and I want to make it universal (iPhone and iPad).
When the application Launches in iPad, I want it to use a split view controller.
I have two classes. The first one is "Rootviewcontroller" and the second one is "Detailview" Controller. In both classes, I use the navigation controller. In the iPhone, when the application launches, rootviewcontroller is visible. Using the navigation controller, the user can move to the detail View.
On the iPad, I want the root view controller to be on the left side of the split view controller, and the detail view on the right side.
If you check out the Apple Documentation, you just have to assign the two view controller when you initialize the UISplitViewController. Here's a link to the Apple Documentation - http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewController_class/Reference/Reference.html
Here's an example from an actual iOS application we have (changed some variable names to make it easy to understand). We basically determine if the device is an iPad or not, then build the master navigation controller.
detailNav is the a navigation controller created with the "detail view controller of our item"
masterNav is the navigation controller used with our iPhones. It starts the users on a tableView which allows them to select an item to move forward to a detail view.
We assign both of these to an array and initialize the split view controller.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detailVC];
NSArray *vcs = [NSArray arrayWithObjects:masterNav, detailNav, nil];
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
[splitViewController detailVC];
[splitViewController setViewControllers:vcs];
[[self window] setRootViewController:splitViewController];
} else {
[[self window] setRootViewController:masterNav];
}
This is most likely not the best code or best practice as me and my team are still fairly new to the iOS world, but I hope it helps. This code is running on a live app in production.