Search code examples
iossegueuistoryboardsegue

what is the correct way to be back to first view controller if not using navigation controller?


enter image description here

I have case that I can't use navigation controller, I want to back from YellowVC to blueVC. if using navigation controller I usually use

self.navigationController?.popToRootViewController(animated: true)

but If I don't use navigation controller I find there is two way to back from blueVC to yellowVC.

  1. using unwind segue
  2. using present modally like the picture below

enter image description here

so what is the best way to back to first view controller? using unwind segue or using present modally segue?


Solution

  • Assuming you are presenting all views, better way is to use unwind Segues.