Jarosław Krajewski
Jarosław Krajewski

Reputation: 520

Restore View State with segue ios

I have setting like this:

First controller reads data and sets in Second Controller. Second Controller has a button that executes push segue to Third Controller with a countdown. After countdown I want to go back from third controller to second that should still have data. Is there any way to achieve this?

Also I am using Storyboards.

I send data to Second Controller in prepare func. Second to Third controller change is connected directly to button in Storyboards.

override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
    let controller = segue.destination as! QuestionViewController
    controller.questionIDs = sender as! [Int]

}

To come back from Third to Second controller I use this code from Third controller:

self.performSegue(withIdentifier: "nobodyAnsweredSegue", sender: self)

Upvotes: 0

Views: 251

Answers (1)

MwcsMac
MwcsMac

Reputation: 7168

Change this:

self.performSegue(withIdentifier: "nobodyAnsweredSegue", sender: self)

To this:

self.navigationController?.popViewControllerAnimated(true)

Upvotes: 1

Related Questions