O'Reilly logo

Programming iOS 4 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Split Views

A split view is implemented through a UISplitViewController (a UIViewController subclass) along with an array of two UIViewControllers whose views are to be displayed in the two regions of the split view. This array is the UISplitViewController’s viewControllers property; it can be configured in code or in a nib. A UIViewController contained in a UISplitViewController has a reference to the UISplitViewController through its splitViewController property.

There is very little work for you to do with regard to a split view. A split view controller has no further properties or methods beyond those inherited from UIViewController. You can hear about what the split view is doing through its delegate (adopting the UISplitViewControllerDelegate protocol):

splitViewController:willHideViewController:withBarButtonItem:forPopoverController:

The split view is rotating to portrait orientation, so it’s hiding the first view. The split view creates a UIBarButtonItem and hands it to you as the third parameter. Your mission, should you decide to accept it, is to put that UIBarButtonItem into the interface, typically in a toolbar at the top of the root view. Of course you are also free to configure the UIBarButtonItem’s title and image as well.

What you do with the other parameters is up to you, but none of them are needed; the split view has already set things up so that if you do put this UIBarButtonItem into the interface, then if the user taps it, a popover will be presented through ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required