I have a universal app and want to add a split view controller for my settings view only. This means that I require a split view controller that isnt the initial view controller which would handle the interaction between SettingMainTableViewController (the main settings page) and SettingDetailViewController (showing the individual settings). All the guides and tutorials I can see online assume that the split view controller is the initial view controller.
The flow would be MainMenuViewController -> SettingMainTableViewController -> SettingDetailViewController which would be displayed as a split if on ipad and not split if iphone. Is this possible to achieve and how would I go about it?
Without setting it as rootViewController
, you can use it in the same way you use other UIViewController
s. You can present in modally or even push it to navigation stack. One of the example is as given below:
let rootViewController: UIViewController = UIViewController()
rootViewController.view.backgroundColor = UIColor.red
let navVC: UINavigationController = UINavigationController(rootViewController: rootViewController)
let detailViewController: UIViewController = UIViewController()
detailViewController.view.backgroundColor = UIColor.blue
let splitVC: UISplitViewController = UISplitViewController()
splitVC.viewControllers = [navVC, detailViewController]
self.present(splitVC, animated: true, completion: nil)
Let me know if you have any doubts