Lindsey
Lindsey

Reputation: 53

Swift - How do you close modal and then segue to another view controller?

I've got a button on a modal window which should segue to another view controller. When I try to directly segue from the modal using push I get an error and when I try to unwind to the view controller before the modal and call the performSegueWithIdentifier to reach the view controller I don't get a segue.

Can anyone help with this?

Code looks like this

//rating page
@IBAction func openVote(segue: UIStoryboardSegue) {
    println("Vote Submitted")
    self.performSegueWithIdentifier("vote", sender: self)
}

On the vote page, which unwinds to the rating page function, I have caused the unwind to happen by connecting a button with the Exit > Action Segue > openVote:

I have another button on the rating page which segues correctly to the new view controller using the segue identifier "vote".

Upvotes: 2

Views: 1079

Answers (1)

Kaushil Ruparelia
Kaushil Ruparelia

Reputation: 1178

Since I can't comment, the modal view controller should be a root View controller of the UINavigationController or at least contain a navigation controller in the hierarchy.

If you are popping the Modal View controller and then performing segue, make sure the segue 'vote' is there on the storyboard.

Note: the unwinding part is a bit confusing, please be more clearer.

Upvotes: 1

Related Questions