UISplitViewController is a container class like UITabViewController, UINavigationController. It separates the main view into two View Controllers masterViewController(PrimaryViewController) and detailViewController(SecondaryViewController). we can send an array with two view controllers and Apple recommends to to UISplitViewController as a rootviewcontroller for your application. To interact between the viewcontrolers I use NSNotificationCenter.
Master and Detail View interaction using Delegates in Objective C
UISplitViewController must be the rootViewController of your application.
Just create an object for the UISplitViewController and set that viewcontroller as the rootviewcontroller for your application.
MasterViewController is always on the left side of the device you can set the width in UISplitViewCOntroller delegate methods and DetailViewController is on the Right side of the application
Created master and detail ViewControllers are added to an array which is set to self.viewControllers in UISplitViewController. self.preferredDisplayMode is is the mode set for displaying of master and DetailViewControllerApple Documentation for DisplayMode
self.presentsWithGesture enables swipe gesture for displaying MasterViewcontroller
Create a DetailViewDelegate delegate with sendSelectedNavController:(UIViewController *)viewController method for sending the UIViewController to the DetailViewcontroller. Then in MasterViewController the mainTableView is the tableview in the leftside. The viewControllerArray contains all the UIViewControllers that needs to be displayed in DetailViewController
Create some UIViewControllers and added it to an array. The Table view is initialized then on didSelectRowAtIndexPath method I send a UIViewController to the DetailViewController using detailDelegate with the corresponding UIViewController in array as parameter
sendSelectedNavController is declared here with removing all the views in the DetailViewController and adding the passed UIViewController from the MasterViewController
Adding some screen shots of the application
On launching the application we don't get MasterViewController since we gave the preferredDisplayMode as automatic on swiping the screen we get the MasterViewController as attached in the below image but in Landscape mode we get both the MasterViewController and DetailViewController
on Landscape Orientiation
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0