Tab Bar/Split View?

I would like to set up a split view with a tab bar. I have found plenty of information on setting up one or the other but not both combed.


Will the split view still remain the root view controller? From what I read I will need code in the AppDelegate and in the MasterViewController to address the fact that both the master and detail views will be active at the same time. Do I need additional code for the tab bar in the app delegate?

Accepted Reply

>I have found plenty of information on setting up one or the other but not both combed.


That would be:


https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/CombiningViewControllers.html


Combined View Controller Interfaces / Order of Containment

Replies

If I remember well, just create the Master / SplitView.


Then select the splitView and execute the menu to insert in Navigation controller.


There is a good tutorial in Stanford course for IOS 10 (ITunes University).

It is lesson "Views gestures and Closures", the lesson 6: Multiple MVCs.


The interesting content is about at 26' ; but I do advise to watch it all.

Claude I found this answer on Stack Overflow that seems to work. The program would crash without setting the tab bar controller to the root controller.


let tabBarViewController = self.window!.rootViewController as! UITabBarController

print(tabBarViewController.viewControllers?.count ?? 0)

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

>I have found plenty of information on setting up one or the other but not both combed.


That would be:


https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/CombiningViewControllers.html


Combined View Controller Interfaces / Order of Containment

And I understand that's what embedding in a navController does behind the scene when you do it in IB.

Claude I did that in the IB but still got the error until I added this code.


KMT thanks for the link. I did a lot of searching but never found that.