iOS 5 Split View Controller Changes

The split view controller was introduced with the iPad back in iOS 3.2 and has not received much in the way of updates since then. It splits the display into two views commonly used to implement master and detail views. In landscape orientation both views are visible with the master view on the left and the detail view on the right. The master view is typically a table with the detail view representing a row in the table as shown below:

In portrait mode the detailed view fills the whole screen and the master view is a popover view usually accessed by a button on the toolbar as shown below:

This is fine but often having a view fill the entire screen of the iPad is a waste of space. Prior to iOS 5 there was no easy way to change this without implementing your own custom split view controller from scratch. Finally with iOS 5 the UISplitViewControllerDelegate protocol has a new delegate method that provides some help. If you implement the splitViewController:shouldHideViewController:inOrientation method in your delegate controller (usually the detail view controller) you can change the default behaviour.

- (BOOL)splitViewController:(UISplitViewController *)svc
   shouldHideViewController:(UIViewController *)vc
              inOrientation:(UIInterfaceOrientation)orientation {
  return NO;
}

If you always return NO regardless of the orientation the master view is no longer hidden in portrait mode resulting in both views being shown as in the example below:

In situations where the detail view cannot sensibly make use of the whole iPad screen this is a big improvement. Of course, you can also now implement the reverse of the pre-iOS 5 behaviour and have the master view appear as a popover only in the landscape orientation:

- (BOOL)splitViewController:(UISplitViewController *)svc
   shouldHideViewController:(UIViewController *)vc
              inOrientation:(UIInterfaceOrientation)orientation
{
  return UIInterfaceOrientationIsLandscape(orientation);
}

This gives a landscape view as follows:

Whether this makes sense or not depends on the application but it is good to at least have some flexibility over how the split view controller works.

One final comment, since this new behaviour is implemented as a new delegate method you can safely implement it, without runtime checks, in apps that must still run on pre iOS 5 devices. On devices running earlier iOS versions this delegate method will never be called and the split view controller will have the default pre IOS 5 behaviour.