Jeef
Jeef

Reputation: 27285

Unwind segue to last view controller

From the examples I've seen unwind segue needs a view controller to unwind to. If i just want to go back one controller in my storyboard is there a simple command for this?

Upvotes: 2

Views: 715

Answers (2)

Rietveld
Rietveld

Reputation: 1

In the newest version of swift it will work like this:

dismiss(animated: true, completion: nil)

Assuming you call this in the view controller script.

Upvotes: 0

jrturton
jrturton

Reputation: 119292

If you've pushed onto a navigation controller (push segues, with a visible back button) then you use this code to go back:

[self.navigationController popViewControllerAnimated:YES];

If you've used modal segues, use this:

[self dismissViewControllerAnimated:YES completion:nil];

In both cases self is the currently visible view controller.

Upvotes: 7

Related Questions