I am trying to utilize UISplitViewController to develop my app for iPad users.
Since my app has a UITabBarController as its root view controller, I want to set this root view controller as a primary view controller in new UISplitViewController hierarchy, and its detail view controller to the secondary column.
Also, when the app's width size class is compact (iPad SplitView mode), I want it to be same as current app. So the root view controller (UITabBarController) should be on the compact column of the new UISplitViewController system like below.
class MySplitViewController: UISplitViewController {
override init(style: UISplitViewController.Style) {
super.init(style: style)
let primaryVC = PrimaryViewController()
let secondaryVC = SecondaryViewController()
setViewController(primaryVC, for: .primary)
setViewController(secondaryVC, for: .secondary)
setViewController(primaryVC, for: .compact)
}
}
With this code, in regular width mode, the primary and secondary column looks great as I expected. When I switch the app to the compact mode, it shows its primary view controller as I intended, too.
But, the problem is that when I return back to the full screen mode in which both the primary and secondary should be there like before I changed it to the compact mode, the primary view controller disappears visually as well as is deallocated.
Am I not allowed to use one view controller in primary and compact column at the same time?