to this point, Dudel has been a fun toy, but it has at least one quite
severe limitation: Apart from sending your drawing as e-mail, you have
no way of saving what you've drawn. As soon as you quit the app, your
work is gone! That's clearly not the way any iPhone or iPad app should
work, so we're going to remedy that, and give the user a way to save
any number of Dudel documents. We'll use a UISplitViewController
to help us out here, so we can display an additional view controller
that shows a list of all relevant files, letting the user switch
between them easily.
The UISplitViewController, like the UINavigationController and UITabBarController,
serves an organizational function. Rather than displaying any content
on its own, it shows the view for an additional controller next to the
main controller view in landscape mode, as shown in Figure 1.
Figure 1. Some inspiring Dudel art. Notice the list of available Dudel files on the left.
The use of the UISplitViewController, in combination with a toolbar at the bottom of the main view, is somewhat unorthodox. The UISplitViewController always creates the left-side view with a title row at the top ("My Dudels" here), and Apple's recommendation when using UISplitViewController
is to put the main view's toolbar (if any) at the top as well. I didn't
do this for Dudel, and it does give the screen a slightly lopsided
appearance. But I think this adds character! Of course, you're free to
move the main view's toolbar to the top if you wish, to bring it more
in line with what Apple recommends. And when you use a UISplitViewController
in your own apps, you should probably put your main view's toolbar at
the top, unless you have a good reason not to (a better reason than my
claims of adding character!). If you rotate the device to portrait
mode, something interesting happens. The UISplitViewController switches gears, and no longer shows a list of files on the left. Instead, it gives a UIBarButtonItem
to its delegate (a view controller of our own), which can then add it
to a toolbar. That button item, when touched, brings up the same view
that was shown on the left side in landscape mode, this time displayed
using a UIPopoverController, as shown in Figure 2.
Figure 2. In portrait mode, the file list is shown only when you click the button that brings up the popover.
This one will require no configuration on our part, since the UISplitViewController sets it up for us. However, we will still be required to dismiss the popover after the user makes a selection.
You might also notice in Figures 1 and 2
that the Email PDF button at the lower right has been swapped out for a
generic action icon button. This will bring up a menu containing a
handful of operations such as creating, renaming, and deleting files,
which set up in this chapter.