iPad: Configuring the split-view controller should happen in init(), not loadView()

This commit is contained in:
Roopesh Chander 2018-11-07 15:54:30 +05:30
parent f8f19ef3d7
commit 1bba1ffe16
1 changed files with 9 additions and 4 deletions

View File

@ -6,18 +6,23 @@ import UIKit
class MainViewController: UISplitViewController { class MainViewController: UISplitViewController {
var tunnelsListVC: TunnelsListTableViewController? var tunnelsListVC: TunnelsListTableViewController?
override func loadView() { init() {
let detailVC = UIViewController() let detailVC = UIViewController()
detailVC.view.backgroundColor = UIColor.white
let detailNC = UINavigationController(rootViewController: detailVC) let detailNC = UINavigationController(rootViewController: detailVC)
let masterVC = TunnelsListTableViewController() let masterVC = TunnelsListTableViewController()
let masterNC = UINavigationController(rootViewController: masterVC) let masterNC = UINavigationController(rootViewController: masterVC)
self.tunnelsListVC = masterVC
super.init(nibName: nil, bundle: nil)
self.viewControllers = [ masterNC, detailNC ] self.viewControllers = [ masterNC, detailNC ]
}
super.loadView() required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
tunnelsListVC = masterVC
} }
override func viewDidLoad() { override func viewDidLoad() {