Thursday, May 3, 2012

Keep both view controllers in UISplitViewController portrait view

Hooray! Apple has created a UISplitViewController delegate to choose whether the master view controller is hidden or not on orientation change. If you start a project with the Master Detail application template, simple edit the [Project]DetailViewController.m file. At the bottom of this file you will find a #pragma mark - Split view, followed by all the delegate methods for the UISplitViewController. Simply add the following: -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { return NO; } That will force the first view controller to stay in view upon orientation change (namely, portrait view.)