2.25. Presenting Master-Detail Views with UISplitViewController

Problem

You want to take maximum advantage of iPad’s relatively large screen by presenting two side-by-side view controllers.

Solution

Use the UISplitViewController class.

Discussion

Split view controllers are present only on the iPad. If you’ve used an iPad, you’ve probably already seen them. Just open the Settings app in landscape mode and have a look. Can you see the split view controller there in Figure 2-73?

Split view controller in the Settings app on the iPad

Figure 2-73. Split view controller in the Settings app on the iPad

A split view controller has left and right sides. The left side displays the main settings, and tapping on each one of those settings shows the details of that setting item on the right side of the split view controller.

Warning

Never attempt to instantiate an object of type UISplitViewController on a device other than an iPad. This will raise an exception.

Apple has made it extremely easy to create split view controller based applications. Simply follow these steps to create your app based on split view controllers:

  1. In Xcode, navigate to the File menu and choose New New Project...

  2. In the New Project screen, pick iOS Application on the left side and then pick Master-Detail Application (as shown in Figure 2-74) and press Next.

  1. In this screen, pick your Product Name and make sure your Device Family is Universal. We want to make sure our app runs both on ...

Get iOS 6 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.