Search code examples
iosswiftuiviewcontrollersigabrt

Pushing a Duplicate View Controller


I'm trying to build a step by step questionnaire app with a View Controller called QuestionController whose content is dynamically populated via some globals in a constants file. When a user is done answering a question, I want to be able to be able to push another QuestionController for the next question.

@IBAction func goNext(_ sender: UIButton) {

    let controller = QuestionController()

    navigationController?.pushViewController(controller, animated: true)

}

As you can see, that is exactly as I have done but for whatever reason I'm getting a SIBABRT error. Any ideas why this might be? I don't have any lingering outlets and the only action is the next button callback you see here.


Solution

  • Instead of this

    let controller = QuestionController()
    

    load it like this with it's identifer in IB

    let controller = storyboard.instantiateViewController(withIdentifier: "identifer") as! QuestionController