forked from shadowfacts/Tusker
Fix crash due to nested navigation controllers
This commit is contained in:
parent
ea07e6aef6
commit
4fa1bd7268
|
@ -67,6 +67,17 @@ class SplitNavigationController: UIViewController {
|
|||
if let rootViewController {
|
||||
rootNav.viewControllers = [rootViewController]
|
||||
}
|
||||
|
||||
// add the child VCs here, rather than in viewDidLoad, because this VC is added to the UISplitViewController,
|
||||
// it needs a UINavigationController to be this VC's first child, otherwise it will embed this VC inside
|
||||
// yet another UINavigationController, which can then cause a crash when we try to embed a nav controller inside
|
||||
// of ourself (because nested nav controllers are forbidden)
|
||||
rootNav.willMove(toParent: self)
|
||||
addChild(rootNav)
|
||||
rootNav.didMove(toParent: self)
|
||||
secondaryNav.willMove(toParent: self)
|
||||
addChild(secondaryNav)
|
||||
secondaryNav.didMove(toParent: self)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
@ -76,10 +87,10 @@ class SplitNavigationController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
embedChild(rootNav, layout: false)
|
||||
embedChild(secondaryNav, layout: false)
|
||||
rootNav.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(rootNav.view)
|
||||
secondaryNav.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(secondaryNav.view)
|
||||
|
||||
separatorView.backgroundColor = .separator
|
||||
separatorView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
Loading…
Reference in New Issue