Reputation: 170
I have a UISplitViewController
showing a UITabBarController
as its detail view (.secondary
). The UITabBarController
shows a UIViewController
embedded in a UINavigationController
.
On iPad (not .compact
), this works great. The UINavigationBar
of the UINavigationController
is shown as there is no push segue from the UISplitViewController
as the views are .tiled
.
However, on iPhone (.compact environment), this presents a problem. When showDetailViewController:
is called, the UISplitViewController
pushes the UITabBarController
, which results in there being a second redundant UINavigationBar
with a “Back” UIBarButtonItem
for the UISplitViewController
's UINavigationBar
, and then right under it is the UINavigationBar
of the UINavigationController
.
Removing the UINavigationController
from the hierarchy fixes the issue on iPhone (or .compact
environments), but introduces an issue on iPad (not .compact
): no UINavigationBar
from the UISplitViewController
is shown at all.
Is there a straightforward solution/protocol for this? I feel as if though this is a pretty common scenario and I’m unsure how to move forward.
To reiterate, the goal is to have one UINavigationBar showing on both iPhone (.compact
) and iPad (not .compact
) for the detail (.secondary
) view of my UISplitViewController
.
Upvotes: 0
Views: 1018
Reputation: 170
For anyone else facing a similar problem (as any similar questions I've found on this site go unanswered), the solution was to instead embed the UITabBarController
into a UINavigationController
.
The UISplitViewController
picks up the fact that it is pushing a UINavigationController
, and merges the UINavigationBar
s. In my original setup, the UITabBarController
acted as a barrier and prevented the UINavigationBar
s from merging.
Upvotes: 1