I have a UISplitViewController embedded in a container view (because it's not at the root of my app), the mechanics of which are working nicely except for one issue: The navigation bar for the detail view is missing on the iPad.
Initial setup is essentially as follows:
- In IB, drag a Split View Controller onto the storyboard, which creates a Split View Controller, a Navigation Controller, a Table View Controller (Master), a basic View Controller (Detail), and the segues connecting them.
- Add a regular View Controller with a Container View. Create an Embed Segue from the Container View to the Split View Controller.
- Add another segue from the Prototype Cell to the Detail View Controller, supported by the following code in the Master Controller:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: "showDetail", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
let destinationViewController = segue.destination as! DetailViewController
let path = self.tableView.indexPathForSelectedRow! as NSIndexPath
destinationViewController.selectedTrainingId = (self.itemList[path.row] as! MyListItem).id
}
}
- Add the data.
Loading the items into master view and selecting the detail are working.
Here is what it looks like in IB (to save space I show the iPhone layout but the relationships should be visible anyhow):
There are few answers in SO dealing with similar problems. Closest matches suggest adding an own navigation controller for the detail view. I did not understand why that would be necessary because the fact that it works as intended on the iPhone I believe shows that the detail view uses the same navigation controller as the master (root) view. But I gave it a try. Result is, as I suspected, that initially a navigation bar is shown. but as soon as an item is selected the bar disappears. Below is the setup.
In many apps (Messaging, Email, Skype, ...) you can see separate top bars for master and detail views. While technically my app does not absolutely need both, it is not really pretty especially with a colored bar. So, the question is: How can I get the Navigation Bar for the Detail View.

