Graphics Programs Reference
In-Depth Information
ler:animated:completion:
, the
UITabBarController
is always the
presenter.
This behavior explains why the
DetailViewController
obscures the
UINaviga-
tionBar
when presented modally but not when presented normally in the
UINaviga-
tionController
's stack. Even though the
ItemsViewController
is told to do
the modal presenting, its oldest ancestor, the
UINavigationController
, actually
carries out the task. The
DetailViewController
is put on top of the
UINaviga-
tionController
's
view
and thus obscures the
UINavigationBar
.
Notice also that the
presentingViewController
and
presentedViewCon-
troller
are valid for every view controller in each family and always point to the old-
est ancestor in the other family.
You can actually override this oldest-ancestor behavior (but only on the iPad). By doing
so, you can specify where the views of the presented view controller family appear on the
screen. For example, you could present the
DetailViewController
and its
navig-
ationController
so that it only obscures the
UITableView
but not the
UINav-
igationBar
.
Every
UIViewController
has a
definesPresentationContext
property for
this purpose. By default, this property is
NO
, which means the view controller will always
pass presentation off to its next ancestor, until there are no more ancestors left. Setting this
property to
YES
interrupts the search for the oldest ancestor, allowing a view controller to
present the modal view controller in its own view (
Figure 13.9
)
. Additionally, you must
set the
modalPresentationStyle
for the presented view controller to
UIModalPresentationCurrentContext
.
Figure 13.9 Presentation context