0

I have a UITableView (let's call it HomeVC) and when you press the cells it takes you to a details page via a show segue. On that details (DetailsVC) page, there is an edit button which modally brings up an edit view (EditVC) with a delete option. When the delete option is pressed, I want to go back to the HomeVC, "unwinding" (if that's the correct term) the EditVC and DetailsVC.

Right now my delete button (in EditVC) brings up an ActionSheet to confirm deletion with the destroy(delete) button doing:

let destroyAction = UIAlertAction(title: "Confirm Delete", style: .Destructive) { (action) in
    //handle deletion stuff...

    // send user back to HomeVC
    self.dismissViewControllerAnimated(false, completion: nil)
    //also tried self.parentViewController?.dismiss...                   
}

The dismissViewController works to get rid of the modal segue from DetailsVC to EditVC, bringing me back to DetailsVC, but since this item is now deleted I don't want to see its details, I want to go all the way back to HomeVC. How could I accomplish this? Can I do it all from EditVC in the function above?

EDIT: If you're coming here from search/google, this is what I used to finally get it: https://stackoverflow.com/a/27879562/2868510

Community
  • 1
  • 1
Tommy K
  • 1,759
  • 3
  • 28
  • 51

1 Answers1

0

try this instead,

self.navigationController?.popViewControllerAnimated(true)
anders
  • 4,168
  • 2
  • 23
  • 31
  • that seems to do nothing. I tried calling just this, calling it after `dismissViewControllerAnimated()`, and calling it in `completion`. The only thing that would happen is the `dismissViewControllerAnimated()` – Tommy K Jul 06 '16 at 21:14