Same as the
previous project,
except that the master view is relegated to a
popover
when the iPad is in
portrait orientation.
The detail view gets a
UIToolBar
with a “50 States”
button
in portrait orientation.
The
UIToolBar
and its button disappear in landscape orientation.
main.m
SplitAppDelegate
MasterViewController
DetailViewController
DetailView
The
DetailViewController
no longer controls the
UIWebView
directly.
It now controls a
DetailView
,
which contains two
subviews:
a
UIToolBar
and a
UIWebView
.
The purpose of the
UIToolBar
is to hold the
UIBarButtonItem
(“50 States”)
for summoning up the master view in a
popover
when the iPad is in landscape orientation.
The
UIToolBar
is visible only when the iPad is in portrait.
When in landscape,
it is rendered invisible by having its
the height
UIToolBar
set to zero
in the
layoutSubviews
method of the
DetailView
.
(Setting the height to zero is simpler than
removing
the
UIToolBar
from its
superview.)
When in portrait,
its height is restored.
The
UIBarButtonItem
is also removed from the
UIToolBar
when the iPad is in landscape.
But this is total overkill because the
UIToolBar
is invisible.
I just wanted to show you how to remove it.
The
DetailViewController
is the object that most urgently
needs to be informed when the orientation changes.
It has to make the
UIToolBar
visible or invisible,
and change the height of the
UIWebView
accordingly.
We therefore let the
DetailViewController
be the delegate of the
UISplitViewController
.
The master view is not longer visible in portrait
(unless we pop up the popover)
because the
UISplitViewController
no longer has the method
splitViewController:shouldHideViewController:inOrientation:
.