iOS 14 UISplitViewController (sidebar) with triple column sidebar toggle icon behavior

I'm implementing the iOS 14 (iPadOS 14) sidebar (UISplitViewController with TripleColumn) and having strange "sidebar toggle icon" behavior.

In iOS 13 I'm using the tab bar with tabs with "split views" and tab with only "table view" so I need the Triple Column instead of the Double Column to work.

In iOS 13, there is one tab with only a table view, so I set the supplementary view to nil, and hide the view by calling "hide" method implemented in UISplitViewController in iOS 14. (See below for code).

The "sidebar toggle icon" on the upper left is automatically displayed. After clicking the toggle icon, the sidebar hides correctly but an "back button" was created on my secondary view(a UITableViewController embedded in a UINavigationController).

Selecting the back button has no response at all. However, user can still swipe from the left edge of the screen to make sidebar reappear but the "back button" is confusing.
My expected behavior is, after the toggle icon selected in sidebar, display the "sidebar toggle icon" instead of the "back button" in the secondary view. And after pressing the "sidebar toggle icon" in secondary view, the sidebar reappears.

Like the Photos app in iPadOS 14, the toggle button is shown instead of the back button in the secondary view. And clicking the toggle icon will make the sidebar shown again. (but it's a double column split view though, not a triple column split view.) 

SceneDelegate.swift:
Code Block
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
if #available(iOS 14.0, *) {
let main = UIStoryboard(name: "Main", bundle: nil)
let splitViewController = UISplitViewController(style: .tripleColumn)
splitViewController.preferredDisplayMode = .twoBesideSecondary
splitViewController.preferredSplitBehavior = .tile
splitViewController.setViewController(SideBarViewController(), for: .primary)
// fall back for compact screen
splitViewController.setViewController(main.instantiateInitialViewController(), for: .compact)
window.rootViewController = splitViewController
self.window = window
window.makeKeyAndVisible()
}
}
}


SideBarViewController.swift:
Code Block
// if the first tab (dashboard) was selected
private func selectDashboardTab() {
if #available(iOS 14.0, *) {
let dashboardVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DashboardTab") as? UINavigationController
splitViewController?.preferredPrimaryColumnWidth = 250.0
splitViewController?.preferredDisplayMode = .twoBesideSecondary
splitViewController?.preferredSplitBehavior = .tile
splitViewController?.setViewController(dashboardVC, for: .secondary)
splitViewController?.setViewController(nil, for: .supplementary)
splitViewController?.hide(.supplementary)
}
}

Replies

I have exactly the same issue, did you manage to fix it somehow?
  • There seems to be a workaround on Stackoverflow

    It basically create a new UISplitViewController and show on the window every time you change the column style. I'm not sure what's the "cost" to create a new UISplitViewController every time the column style changed? Does the old UISplitViewController get cleaned up in the memory?

Add a Comment