How to embed a tab bar controller with a split view controller in swift?

im suggesting there should be changes in the application delegate? Thanks for the help!

+4
source share
1 answer

1) Create a Master / Detail sample via xcode

2) Drag TabBarControllerinto the storyboard

3) Change TabBarControllerto the initial view controller.

4) Control Drag from TabBarControllertoSplitViewController

5) Assign a title SplitViewControllerto the storyboard

6) In the application delegate, replace the link with the SplitViewControllerfollowing.

let tabBarViewController = self.window!.rootViewController as! UITabBarController
print(tabBarViewController.viewControllers?.count)
var splitViewController:UISplitViewController? = nil
for viewController in tabBarViewController.viewControllers! {
if viewController.title == "Master" {
    splitViewController = viewController as? UISplitViewController
}
}

let navigationController = splitViewController!.viewControllers[splitViewController!.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController!.displayModeButtonItem()
splitViewController!.delegate = self
+11
source

All Articles