Search code examples
iosswiftipados

Hide only .supplementary column in UISplitViewController


I've set up a UISplitViewController with style .tripleColumn.

let splitViewController = UISplitViewController(style: .tripleColumn)
preferredDisplayMode = .twoBesideSecondary
preferredSplitBehavior = .tile

For the first menu item "My Stories" it needs three columns. However, for all the other menu items it should only be the primary column (sidebar) and the content visible. The .supplementary column should be hidden.

enter image description here

When clicking on "My stats" for example, the following code hides both the .primary (sidebar) and .supplementary column and only shows "My Stats".

splitViewController?.showDetailViewController(stats, sender: nil)
splitViewController?.hide(.supplementary)

How can I switch to a .twoColumn style and only have the .primary and .secondary column visible?


Solution

  • In a .tripleColumn split view controller, by design, it is impossible for the .primary column to appear without also showing the .supplementary column.

    And you cannot change one and the same split view controller from being a .tripleColumn to being a .doubleColumn. I suppose you could just rip the entire split view controller right out of the interface and substitute a different one, but is that really what you want to do? I think it would be better to use the split view controller the way it is designed to be used.