Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamesrochabrun/3e5a69308a0145c9a1a40b3598d731ac to your computer and use it in GitHub Desktop.
Save jamesrochabrun/3e5a69308a0145c9a1a40b3598d731ac to your computer and use it in GitHub Desktop.
/// 1 convenience init.
convenience init(viewControllers: [UIViewController]) {
self.init()
/// 2 set master and detail, it takes an array of view controllers.
self.viewControllers = viewControllers
/// 3 preferredDisplayMode, it defines the display mode of the split view controller,
/// .allVisible will display both master and detail.
preferredDisplayMode = .allVisible
/// set the delegate to self to allow the `SplitViewController` handle the UISplitViewControllerDelegate methods.
super.delegate = self
}
/// 4
let profileMasterViewController = UINavigationController(rootViewController: ProfileViewController())
let profileSplitViewController = SplitViewController(viewControllers: [profileMasterViewController, EmptyDetailViewcontroller()])
profileSplitViewController.tabBarItem.image = viewModel.icon /// some image.
/// 5 Lastly in `TabBarController` instance...
final class TabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
/// 6
viewControllers = [profileSplitViewController...] /// add any other controller that you want here.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment