Isaaс Weisberg
Isaaс Weisberg

Reputation: 2814

UINavigationController push crash

I have a NestedViewController which I am trying to push into a UINavigationController. This causes a crash with a following stack trace:

enter image description here

Additionally:

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.

enter image description here

The scene tree, while at it, started to look like this:

enter image description here

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)

Upvotes: 1

Views: 212

Answers (2)

Andy Darwin
Andy Darwin

Reputation: 478

Check this stackOverflow

The crash info is obscure. Hope it can inspire you.

Upvotes: 0

Isaaс Weisberg
Isaaс Weisberg

Reputation: 2814

As stated in UPD5, the controller you are pushing into the navigation controller is literally that same controller itself.

Upvotes: 1

Related Questions