0

Using Swift, i'm opening a second view controller like this:

let vwStartTransaction = self.storyboard!.instantiateViewControllerWithIdentifier("StartTransactionView") as TransactionViewController;
self.presentViewController(vwStartTransaction, animated: true, completion: nil);

and then, within that second view, i'm opening a third one in the same way.

let vwConfirmTransaction = self.storyboard!.instantiateViewControllerWithIdentifier("ConfirmTransactionView") as ConfirmViewController;
self.presentViewController(vwConfirmTransaction, animated: true, completion: nil);

Now, when pressing the "Confirm" button in this confirmation controller, i want to close both views so that i'm back in the initial view. Can anyone tell me what the best approach is realise this?

Abizern
  • 129,329
  • 36
  • 198
  • 252
Tys
  • 3,298
  • 7
  • 42
  • 68

2 Answers2

1

You can use storyboards to define your transitions using segues and then use unwindToSegue for back navigation as required

What are Unwind segues for and how do you use them?

Community
  • 1
  • 1
Rajeev Bhatia
  • 2,894
  • 1
  • 17
  • 29
1

Why not use one ViewController and then have the two views displayed. Then you could hide or show them at will and dismiss the single VC when you are done. But if you must do it this way then dismiss the one VC and send a message to the other one to dismiss as well.

AMAN77
  • 5,580
  • 7
  • 42
  • 59
  • Although i like the other approach as well, i'm going with this one for now. Thanks. – Tys Oct 30 '14 at 23:19