I have a NestedViewController which I am trying to push into a UINavigationController. This causes a crash with a following stack trace:
Additionally:
- All of this is happening on the main thread
- This reproduces both on iOS 11 and 12
animated
flag doesn't change anything- NestedViewController gets modally presented somewhere else in the app and it does so successfully, without crashing
- NestedViewController gets its layout from a storyboard
- NestedViewController with its view initialized programmatically and identical to storyboards layout still causes a crash
- Pushing an empty UIViewController doesn't cause a crash
What am I doing wrong?
UPD1: I made this yet this doesn't cause a crash:
let controlla = { () -> UIViewController in
let cont = UIViewController()
cont.view = {
let view = UIView()
view.backgroundColor = UIColor.green
let stack = UIStackView(arrangedSubviews: [ {
let view = UIView()
view.backgroundColor = UIColor.yellow
view.snp.makeConstraints { make in
make.height.equalTo(128)
}
return view
}() ])
view.addSubview(stack)
stack.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
}
return view
}()
return cont
}()
controller.pushViewController(controlla, animated: true)
UPD2: On the request of user Adeel in the comment here is what it says in the console upon an abort breakpoint hit:
libc++abi.dylib: terminating with uncaught exception of type NSException
If it was so simple and the message was there, this question wouldn't really exist, would it.
UPD3: So to extend my investigation I have uninstalled all of the views inside the view controller except for the root one.
The scene tree, while at it, started to look like this:
Then, of course, I got rid of all outlets and the code that was in the view controller.
It still crashes. The modal present still works fine though.
UPD4: I renamed the NestedViewController into some other name just in case. Didn't work.
UPD5: Before UPD1 it looked like this:
controller.pushViewController(controller, animated: true)