Last active
May 8, 2020 20:30
-
-
Save jamesrochabrun/3e5a69308a0145c9a1a40b3598d731ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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